Liferay 搜索容器中的搜索框

Liferay 搜索容器中的搜索框,liferay,Liferay,大家好,图片上的人在这里! 我只是想问一下,当用户在搜索框中键入一个名称时,应该显示特定的字段。我把我的view.jsp代码也放在这里 Vuew.jsp .包装纸{ 文本对齐:居中; } .按钮{ 位置:绝对位置; 最高:20%; } 员工推荐 是的,一旦完成,我们可以为此编写动态查询并重建服务。 完成此操作的步骤。 1:-首先,我们必须在localserviceimpl.java中编写一个动态查询,以便在重建服务时,它将在localserviceutil.java中生成方法 2:-我们可

大家好,图片上的人在这里! 我只是想问一下,当用户在搜索框中键入一个名称时,应该显示特定的字段。我把我的view.jsp代码也放在这里

Vuew.jsp


.包装纸{
文本对齐:居中;
}
.按钮{
位置:绝对位置;
最高:20%;
}


员工推荐
是的,一旦完成,我们可以为此编写动态查询并重建服务。 完成此操作的步骤。 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);
        }
}
package com.data.dbservice.service.impl;
导入java.util.List;
导入com.data.dbservice.service.base.StudentLocalServiceBaseImpl;
导入com.liferay.portal.kernel.dao.orm.DynamicQuery;
导入com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
导入com.liferay.portal.kernel.dao.orm.Junction;
导入com.liferay.portal.kernel.dao.orm.Property;
导入com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
导入com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
导入com.liferay.portal.kernel.exception.SystemException;
导入com.liferay.portal.kernel.util.OrderByComparator;
导入com.liferay.portal.kernel.util.Validator;
导入com.data.dbservice.model.Student;
导入com.data.dbservice.service.StudentLocalServiceUtil;
/**
*学生本地服务的实施。
*
*
*所有自定义服务方法都应该放在这个类中。每当添加方法时,重新运行ServiceBuilder将其定义复制到{@link com.data.dbservice.service.StudentLocalService}接口中。
*
*
*这是本地服务。此服务的方法不会基于传播的JAAS凭据进行安全检查,因为只能从同一VM内访问此服务。
*

* *@作者阿披实 *@请参阅com.data.dbservice.service.base.StudentLocalServiceBaseImpl *@请参阅com.data.dbservice.service.StudentLocalServiceUtil */ 公共类StudentLocalServiceImpl扩展了StudentLocalServiceBaseImpl{ 公共列表getSerachStudents(字符串firstName、字符串lastName、int studentAge、int studentGender、字符串studentAddress、, 布尔andSearch、int start、int end、OrderByComparator和OrderByComparator) 抛出系统异常 { DynamicQuery DynamicQuery=buildStudentDynamicQuery(名字、姓氏、学生年龄、学生性别、学生地址和搜索); return StudentLocalServiceUtil.dynamicQuery(dynamicQuery、start、end、orderByComparator); } public int getSearchStudentsCount(字符串firstName、字符串lastName、int studentAge、int studentGender、字符串studentAddress、boolean和search) 抛出系统异常 { DynamicQuery DynamicQuery=buildStudentDynamicQuery(名字、姓氏、学生年龄、学生性别、学生地址和搜索); return(int)StudentLocalServiceUtil.dynamicQueryCount(dynamicQuery); } 受保护的DynamicQuery buildStudentDynamicQuery(String firstName、String lastName、int studentAge、int studentGender、String studentAddress、boolean和Search) { 连接=空; 如果(和搜索) 连接=限制FactoryUtil.conjunction(); 其他的 连接=限制FactoryUtil.disconction(); if(Validator.isNotNull(firstName)) { Property=PropertyFactoryUtil.forName(“firstName”); 字符串值=(新的StringBuilder(“%”)。追加(firstName)。追加(“%”)。toString(); add(property.like(value)); } if(Validator.isNotNull(lastName)) { Property=PropertyFactoryUtil.forName(“lastName”); 字符串值=(新的StringBuilder(“%”)。追加(lastName)。追加(“%”)。toString(); add(property.like(value)); } 如果(学生年龄>0) { Property=PropertyFactoryUtil.forName(“studentAge”); add(property.eq(Integer.valueOf(studentAge)); } 如果(学生性别>0) { Property=PropertyFactoryUtil.forName(“学生性别”); add(property.eq(Integer.valueOf(studentGender)); } if(Validator.isNotNull(studentAddress)) { Property=PropertyFactoryUtil.forName(“studentAddress”); 字符串值=(新的StringBuilder(“%”)。追加(studentAddress)。追加(“%”)。toString(); add(property.like(value)); } DynamicQuery DynamicQuery=DynamicQueryFactoryUtil.forClass(Student.class,getClassLoader()); 返回dynamicQuery.add(连接); } }
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);
        }
}