0
votes

hi folks as per Search box in Search conatiner Image is here ! i just wanted to ask when the user type a name in search box then the particular field should be display.i am putting my view.jsp code is here also??

Vuew.jsp <%@page import="com.proliferay.servicebuilder.service.BlobDemoLocalServiceUtil"%> <%@ 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

1 Answers

0
votes

yeah itz been completd , we can write a dynamic query for this and rebuild the sevices. steps to do this. 1:- first we have to write a dynamic query in localserviceimpl.java so that when we rebuild the services it will generate the methods in localserviceutil.java 2:- and we can call in this methods in search form search container using display terms . 3:- we can easily search using any keyvalue.

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);
        }
}