当前位置: 首页 > 知识库问答 >
问题:

搜索容器中的搜索框

瞿子濯
2023-03-14

大家好,根据搜索框中的conatiner图像在这里!我只是想问当用户在搜索框中键入一个名称时,应该显示特定的字段。我把我的视图。JSP代码也在这里吗??

vuew.jsp<%@page import=“com.privery.servicebuilder.service.blobdesolocalserviceutil”%><%@taglib uri=“http://java.sun.com/portlet_2_0”prefix=“portlet”%><%@taglib uri=“http://liferay.com/tld/aui”prefix=“aui”%><%@taglib uri=“http://liferay.com/tld/ui”prefix=“liferay-ui”%>

<%@page import="javax.portlet.PortletURL"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<liferay-theme:defineObjects />
<portlet:defineObjects />


<style>
.wrapper {
    text-align: center;
}

.button {
    position: absolute;
    top: 20%;
}
</style>

<%
PortletURL addEmp = renderResponse.createRenderURL();
addEmp.setParameter("mvcPath", "/html/blobdemo/add.jsp");



 PortletURL homeURL = renderResponse.createRenderURL();

PortletURL iteratorURL=renderResponse.createRenderURL();
iteratorURL.setParameter("mvcPath", "/html/blobdemo/display_student.jsp");

PortletURL addEmployee = renderResponse.createRenderURL();
addEmployee.setParameter("mvcPath", "html/blobdemo/add_emp.jsp");

PortletURL employeeDetailsURL = renderResponse.createRenderURL();
employeeDetailsURL.setParameter("mvcPath", "/html/empref/student_details.jsp");

PortletURL displaySearchStudent = renderResponse.createRenderURL();
displaySearchStudent.setParameter("mvcPath", "/html/blobdemo/view.jsp");






%>




<a href="<%=homeURL.toString() %>">Home</a><br/><br/>

<div class="wrapper">
    <button class="btn btn-info"  >Employee Referral</button>
</div>

<button class="btn btn-info"><a href="<%=addEmp.toString()%>">Refer an Employee</button></a>


<!-- <form class="form-search">
  <input type="text" class="input-medium search-query" style="margin-left: 571px;margin-top:-25px;"> -->


  <!-- --search button -->



  <input name="<portlet:namespace/>search" type="text" style="margin-top: -42px;margin-left: 663px;"/>  
    <input type="submit" label="" value="search"  

  style="    margin-top: -40px" formaction="" name="stdForm"  >



 <!-- -search button ends here! -->


         <liferay-ui:search-container   emptyResultsMessage="There is no data to display">
            <liferay-ui:search-container-results
                results="<%=BlobDemoLocalServiceUtil.getBlobDemos(
                                searchContainer.getStart(), searchContainer.getEnd())%>"
                total="<%= BlobDemoLocalServiceUtil.getBlobDemosCount() %>" />

            <liferay-ui:search-container-row className="com.proliferay.servicebuilder.model.BlobDemo" modelVar="aBlobDemo">         
                <portlet:resourceURL var="viewURL"> <portlet:param name="dataId" value="<%=String.valueOf(aBlobDemo.getBlobId())%>" />
                </portlet:resourceURL>              
                <liferay-ui:search-container-column-text
                    value="<%=String.valueOf(row.getPos() + 1)%>" name="Serial No" />       

    <liferay-ui:search-container-column-text   property="customer" name="customer"  />

    <liferay-ui:search-container-column-text   property="referral" name="referral ID"  />
    <liferay-ui:search-container-column-text   property="candidateName" name="Candidate Name"  />
    <liferay-ui:search-container-column-text   property="contactNumber" name="Contact Number"  />
    <liferay-ui:search-container-column-text   property="qualification" name="Qualification "  />
    <liferay-ui:search-container-column-text   property="interviewdateandtime" name="interviewdateandtime"  />
    <liferay-ui:search-container-column-text   property="tenetavijoiningdate" name="Tenetavijoiningdate"  />
    <liferay-ui:search-container-column-text   property="status" name="Status "  />
    <liferay-ui:search-container-column-text   property="actualjoiningdate" name="Actualjoiningdate"  />
    <liferay-ui:search-container-column-text   property="tanurityindays" name="Tanurityindays "  />
    <liferay-ui:search-container-column-jsp path="/html/blobdemo/action.jsp"    align="right" />        





            </liferay-ui:search-container-row>      
            <liferay-ui:search-iterator />
        </liferay-ui:search-container> 


 </form>

共有1个答案

顾宣
2023-03-14

是的,已经完成了,我们可以为此编写一个动态查询并重建sevices。执行此操作的步骤。1:-首先,我们必须在LocalServiceImpl.java中编写一个动态查询,这样当我们重新构建服务时,它将在LocalServiceUtil.java中生成方法2:-我们可以使用显示术语在搜索表单搜索容器中调用这些方法。3:-我们可以使用任何键值轻松搜索。

package com.data.dbservice.service.impl;

import java.util.List;

import com.data.dbservice.service.base.StudentLocalServiceBaseImpl;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
import com.liferay.portal.kernel.dao.orm.Junction;
import com.liferay.portal.kernel.dao.orm.Property;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.Validator;
import com.data.dbservice.model.Student;
import com.data.dbservice.service.StudentLocalServiceUtil;

/**
 * The implementation of the student local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.data.dbservice.service.StudentLocalService} interface.
 *
 * <p>
 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
 * </p>
 *
 * @author Abhishek
 * @see com.data.dbservice.service.base.StudentLocalServiceBaseImpl
 * @see com.data.dbservice.service.StudentLocalServiceUtil
 */
public class StudentLocalServiceImpl extends StudentLocalServiceBaseImpl {
    public List getSerachStudents(String firstName,String lastName,int studentAge,int studentGender,String studentAddress,

            boolean andSearch, int start, int end, OrderByComparator orderByComparator)
            throws SystemException
        {
            DynamicQuery dynamicQuery = buildStudentDynamicQuery(firstName, lastName, studentAge, studentGender, studentAddress, andSearch);
            return StudentLocalServiceUtil.dynamicQuery(dynamicQuery, start, end, orderByComparator);
        }

        public int getSearchStudentsCount(String firstName,String lastName,int studentAge,int studentGender,String studentAddress,boolean andSearch)
                throws SystemException
        {
            DynamicQuery dynamicQuery = buildStudentDynamicQuery(firstName, lastName, studentAge, studentGender, studentAddress, andSearch);
            return (int)StudentLocalServiceUtil.dynamicQueryCount(dynamicQuery);
        }

        protected DynamicQuery buildStudentDynamicQuery(String firstName,String lastName,int studentAge,int studentGender,String studentAddress,boolean andSearch)
        {
            Junction junction = null;
            if(andSearch)
                junction = RestrictionsFactoryUtil.conjunction();
            else
                junction = RestrictionsFactoryUtil.disjunction();

            if(Validator.isNotNull(firstName))
            {
                Property property = PropertyFactoryUtil.forName("firstName");
                String value = (new StringBuilder("%")).append(firstName).append("%").toString();
                junction.add(property.like(value));
            }
            if(Validator.isNotNull(lastName))
            {
                Property property = PropertyFactoryUtil.forName("lastName");
                String value = (new StringBuilder("%")).append(lastName).append("%").toString();
                junction.add(property.like(value));
            }
            if(studentAge > 0)
            {
                Property property = PropertyFactoryUtil.forName("studentAge");
                junction.add(property.eq(Integer.valueOf(studentAge)));
            }
            if(studentGender > 0)
            {
                Property property = PropertyFactoryUtil.forName("studentGender");
                junction.add(property.eq(Integer.valueOf(studentGender)));
            }
            if(Validator.isNotNull(studentAddress))
            {
                Property property = PropertyFactoryUtil.forName("studentAddress");
                String value = (new StringBuilder("%")).append(studentAddress).append("%").toString();
                junction.add(property.like(value));
            }
            DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Student.class, getClassLoader());
            return dynamicQuery.add(junction);
        }
}
 类似资料:
  • 我已经使用Liferay搜索容器来显示自定义实体的数据,它正在工作。我有另一个portlet,其中数据来自RESTAPI,所以有没有任何方法可以使用搜索容器?或者我需要使用datatable。我的REST API有分页和无分页。

  • 我有大量相同类型的实体,每个实体都有大量属性,并且我只有以下两种选择来存储它们: 将每个项存储在索引中并执行多索引搜索 将所有enties存储在单个索引中,并且只搜索1个索引。 一般而言,我想要一个时间复杂度之间的比较搜索“N”实体与“M”特征在上述每一种情况!

  • 我在我的代码中使用了riveray-ui:搜索容器。 搜索结果正在正确显示,直到我单击下一步。portlet正在重新加载,这将把我带到portlet的第一页,丢弃呈现的搜索结果。 即使在重新加载portlet之后,我如何保留搜索结果?

  • 我有以下格式的弹性搜索文档 } } 我的要求是,当我搜索特定字符串(string.string)时,我只想获得该字符串的FileOffSet(string.FileOffSet)。我该怎么做? 谢谢

  • 我正在阅读Solr In Action这本书,对变暖搜索者有点困惑。有人提到 如果正在进行提交,Solr允许陈旧读取,并且在新搜索器预热之前不会关闭当前搜索器。 但之后的一些声明解释了useColdSearcher useColdSearcher=false表示在所有预热查询完成之前,所有对solr的操作都将被阻止 useColdSearcher=true意味着新的搜索器在预热查询完成执行之前就已

  • 我们有一个自定义的职位类型hr priority,它有多个与之相关的自定义分类。这些分类法包含多个术语,每个帖子可以从这些分类法中分配1到多个术语。我们正在尝试设置一个过滤器,允许访问者在多个分类中通过这些术语的组合来搜索/过滤结果。 例如:文章"样本文章"在分类学"年份"中有术语"2018","组织"分类学中有术语"理事会成员","国家"分类学中有术语"加拿大"。文章“其他样本”中有“年份”一词