首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >搜索容器中的搜索框

搜索容器中的搜索框
EN

Stack Overflow用户
提问于 2016-04-11 05:56:16
回答 1查看 1.9K关注 0票数 0

大家好,根据搜索器中的搜索框图片是在这里!我只是想问一下,当用户在搜索框中输入名称时,应该显示特定的字段。我正在将我的view.jsp代码也放在这里?

<%@ import="com.proliferay.servicebuilder.service.BlobDemoLocalServiceUtil"%> <%@ taglib uri="0“prefix="portlet"%> <%@ taglib uri="http://liferay.com/tld/aui”prefix="aui"%> <%@ taglib uri="http://liferay.com/tld/ui“prefix=”prefix=“%>

代码语言:javascript
复制
<%@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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-15 09:39:38

是的,我们可以编写一个动态查询并重建服务。这样做的步骤。1:-首先,我们必须用localserviceimpl.java编写动态查询,以便在重新构建服务时,它将生成localserviceutil.java 2中的方法:-我们可以使用显示项在搜索表单搜索容器中调用此方法。3:-我们可以很容易地使用任何键值进行搜索。

代码语言:javascript
复制
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);
        }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36540813

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档