`

liferay - portlet 数据页面展现.

阅读更多
下面是我实现页面展现数据的时候view-accountlock.jsp ,只是一个JSP而已。
%>
<%@ page import="com.liferay.portal.kernel.dao.search.ResultRow" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import=" java.util.List"%>
<%@ page import="javax.portlet.PortletConfig"%>
<%@ page import="com.ext.portlet.accountlock.AccountLock"%>
<%@ page import="com.ext.portlet.accountlock.model.AccountLockModel "%>
<%@ page import="com.ext.portlet.accountlock.service.AccountLockServiceUtil "%>
<%@ page import="com.ext.portlet.training.model.TrainingModel "%>
<%@ page import="javax.portlet.RenderRequest"%>
<%@ page import="javax.portlet.RenderResponse "%>
<%@ page import="javax.portlet.WindowState "%>
<%@page import="com.ext.portlet.accountlock.search.AccountLockSearch" %>




<%@ include file="/html/portlet/ext/accountlocks/init.jsp" %>

<%
//List allAccountLocks = (List)request.getAttribute("allAccountLocks");
//List passports = (List)request.getAttribute("passports");
//List reasons = (List)request.getAttribute("reasons");
//List beginDates = (List)request.getAttribute("beginDates");
//List endDates = (List)request.getAttribute("endDates");
//List locks = (List)request.getAttribute("locks");
%>


<hr>
        <%
        // searchContainer
        PortletURL portletURL = renderResponse.createRenderURL();
        portletURL.setParameter("struts_action", "/ext/accountlocks/view_accountlocks");       
       
        //object设置标题
        String EMPTY_RESULTS_MESSAGE ="no-data-were-found";
        List<String> headerNames = new ArrayList<String>();
        headerNames.add("passport");
        headerNames.add("reason");
        headerNames.add("beginDate");
        headerNames.add("endDate");
        headerNames.add("locks");
        headerNames.add(StringPool.BLANK);     
        int pageDelta = 10;
        AccountLockSearch searchContainer = new AccountLockSearch( renderRequest, portletURL);
        //SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, pageDelta, portletURL, headerNames, EMPTY_RESULTS_MESSAGE);
      
        //we can set parame or object
        %>
        <%
通过此方法去查询数据集合..
        List allAccountLocks = AccountLockServiceUtil.getService().getAllAccounts();
        //int size = EX_ScheduleEntryLocalServiceUtil.searchCount('');
        int size = allAccountLocks.size();//设置页面显示的总数
        //
        searchContainer.setTotal(size);
        //searchContainer.setDelta(20);每页显示多少条
        
       
        //List results =  EX_ScheduleEntryLocalServiceUtil.search('',searchContainer.getStart(), searchContainer.getEnd());
       
        searchContainer.setResults(allAccountLocks);
        //Table acounts
        List resultRows = searchContainer.getResultRows();
        //assign checkbox
        searchContainer.setRowChecker(new RowChecker(renderResponse));
       
        for (int i = searchContainer.getStart(); i < allAccountLocks.size(); i++) {
   
            AccountLockModel scheduleSearch = (AccountLockModel)allAccountLocks.get(i);

            // create new row  添加一行 
            ResultRow row = new ResultRow(scheduleSearch,scheduleSearch.getPrimaryKey(),i);
           
            // URL 返回searchcontainer,
           
            PortletURL rowURL = renderResponse.createRenderURL();
           
            rowURL.setWindowState(WindowState.MAXIMIZED);
           
            rowURL.setParameter("struts_action", "/ext/accountlocks/view_accountlocks");
            rowURL.setParameter("redirect", currentURL );
            rowURL.setParameter("passport", String.valueOf(scheduleSearch.getPassport()));
           
设置每一行显示的内容
            row.addText(scheduleSearch.getPassport(),rowURL);
           
            row.addText(scheduleSearch.getReason(),rowURL);
           
            if(scheduleSearch.getBeginDate() != null ){
           
            row.addText(dateFormatDateTime.format(scheduleSearch.getBeginDate()),rowURL);
            }else {
             row.addText("",rowURL);
             }
           
             if(scheduleSearch.getEndDate() != null ){
            row.addText(dateFormatDateTime.format(scheduleSearch.getEndDate()),rowURL);
             }else {
             row.addText("",rowURL);
             }
           
                   
            row.addText(""+scheduleSearch.getLock(),rowURL);
           
           
            // assign every data table Action
   
            //row.addJSP("right", SearchEntry.DEFAULT_VALIGN, "/html/portlet/ext/schedule/schedule_action.jsp");
           
           
            resultRows.add(row);
            //此处特别注意,是我自己加的一个方法设置分页的。以及for循环里面的Start()方法。
            if(resultRows.size() >= searchContainer.getDelta())
                break;
       
        }
     %>
   
//分页,searchcontainer 自身控制的分页
     <liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />

  

  



分享到:
评论

相关推荐

    Liferay-Portlet-SDK5.2.3.rar_liferay_liferay sdk_portlet

    - **文档**:如“Liferay-Portlet-SDK 5.2.3操作说明.ppt”文件,它详细介绍了SDK的使用方法,包括portlet的开发流程、配置、部署以及调试技巧。这份文档通常会涵盖portlet生命周期、portlet上下文、渲染和事件处理...

    liferay-portlet-icefaces-archetype-6.1.30.zip

    commons-configuration-gae.zip,配置的实现(由apache commons配置库提供),使用google app engine datastore api存储配置参数;配置的实现(由apache commons配置库提供),使用google app engine datastore api...

    liferay-plugins-sdk-6.1.1-20130816114619181.zip

    此外,SDK还包括了构建脚本(如`build.xml`)和配置文件(如`liferay-plugin-package.xml`),这些文件用于控制项目的构建过程和插件的元数据。`build.xml`通常使用Ant构建工具,定义了编译、测试、打包和部署的步骤...

    render-public-portlet-5.2.6.1.zip_5 to 1

    【标题】"render-public-portlet-5.2.6.1.zip_5 to 1" 指的是一款名为 "render-public-portlet" 的Liferay Portlet的版本5.2.6.1的升级包,它经过了从5到1的优化或改进。这个zip文件可能是用于更新现有Liferay实例中...

    liferay-servicebuilder-archetype-6.1.1.zip

    【标题】"liferay-servicebuilder-archetype-6.1.1.zip" 是一个与Liferay门户框架相关的开源项目构建工具。Liferay是一款流行的开源企业级门户平台,它提供了多种服务来帮助开发者创建、管理和集成Web应用。"service...

    liferay-faces-bridge-impl-3.0.0-ga1.zip

    总之,"liferay-faces-bridge-impl-3.0.0-ga1.zip"和"duckapter.zip"代表了Java开发领域中的两个关键点:portlet和JSF的集成以及静态语言中的鸭子类型实现。通过了解和使用这些工具,开发者能够更好地利用开源资源,...

    liferay-ide-eclipse-updatesite-1.1.0.zip

    在IT行业中,Liferay IDE是一款专为Liferay Portal开发设计的强大工具,而"Liferay-ide-eclipse-updatesite-1.1.0.zip"正是这个工具的更新站点包,它提供了针对Liferay 6.0版本的定制化集成开发环境。Liferay IDE是...

    using-liferay-portal-6.2.pdf

    9.2 Managing Events and Resources with Liferay’s Calendar Portlet . . . . . 211 9.3 Discuss, Ask, and Answer Using the Message Boards . . . . . . . . . . . 221 9.4 Working together with the Wiki . . ...

    liferay-portal-tomcat-5.5-5.1.1.part4.rar

    liferay-portal-tomcat-5.5-5.1.1.part4.rar

    liferay-portal-tomcat-5.5-5.1.1.part1.rar

    liferay-portal-tomcat-5.5-5.1.1.part1.rar

    liferay-portal-tomcat-5.5-5.1.1.part2.rar

    liferay-portal-tomcat-5.5-5.1.1.part2.rar

    liferay-portal-tomcat-5.5-5.1.1.part3.rar

    liferay-portal-tomcat-5.5-5.1.1.part3.rar

    liferay-portlet-development-guide-4.3

    《Liferay Portlet Development Guide 4.3》是针对Liferay Portal平台的一份详细开发指南,旨在帮助开发者理解和创建portlet应用程序。Liferay Portal是一个开源的企业级门户系统,它提供了丰富的功能,如用户管理、...

    liferay-portlet-development

    《Liferay Portlet 开发——全面指南》:深入解析与实战技巧 本书旨在为开发者提供一份详尽的Liferay Portlet开发指南,涵盖从基础知识到实际应用的全面内容。Liferay是一款开源的企业级门户平台,它支持高度定制化...

    liferay-portal-src-6.0.6-20110225.part2

    liferay-portal-src-6.0.6-20110225.part2

    liferay-spring-mvc-portlet:Liferay Spring MVC portlet 的项目模板

    Liferay Spring Portlet MVC 使用 Maven 的 Liferay Spring Portlet MVC 项目模板。 Liferay EE 6.2.10.11 (GA1, SP... $ cp target/liferay-spring-mvc-portlet.war $LIFERAY_HOME/deploy/ 配置 默认设置为 Liferay

    liferay-spring-portlet

    【标题】"liferay-spring-portlet"是一个基于Spring框架构建的portlet应用,适用于Liferay门户平台。这个项目展示了如何将Spring与Liferay Portal结合,创建一个可直接部署到Liferay中的WAR包。作者提到他们已经花费...

    spring-webmvc-portlet.rar

    Portlet框架是为portlet容器(如Liferay、WebSphere Portal)提供的一套标准,它定义了portlet的生命周期、渲染机制以及portlet间通信的规则。portlet是一种独立的、可重用的Web组件,可以嵌入到portlet门户中,提供...

Global site tag (gtag.js) - Google Analytics