2016-04-11 42 views
0

こんにちは、お一人様Search box in Search conatiner画像はコチラ! 私はちょうどユーザーが検索ボックスに名前を入力したら、特定のフィールドはdisplay.iでなければなりません。私のview.jspコードを入れていますか?検索コンテナの検索ボックス

Vuew.jsp <%の@ページのインポート= "com.proliferay.servicebuilder.service.BlobDemoLocalServiceUtil" %> <% @ taglibをURI = "http://java.sun.com/portlet_2_0" プレフィックス=」ポートレット "%> <%@ 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> 

答えて

0

これは動的クエリを作成し、サービスを再構築することができます。これを行う手順は です。 1:まずlocalserviceimpl.javaに動的クエリを記述する必要があります。サービスを再構築すると、localserviceutil.javaのメソッドが生成されます 2: - このメソッドは、検索フォームの検索コンテナでdisplayを使用して呼び出すことができます条項 。 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); 
     } 
} 
関連する問題