Skip to content

Instantly share code, notes, and snippets.

@lipusz
Created June 19, 2013 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lipusz/5814969 to your computer and use it in GitHub Desktop.
Save lipusz/5814969 to your computer and use it in GitHub Desktop.
This is a sample Liferay portlet to demonstrate ice:dataPaginator in action. It was developed under liferay-plugins-sdk-5.2.6.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/.svn/**|.svn/" kind="src" path="docroot/WEB-INF/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/portal-5.2.6"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/commons-beanutils-1.8.0.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/commons-collections-3.2.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/commons-digester-1.8.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/icefaces-ee-3.2.0-ga.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/icefaces-ee-ace-3.2.0-ga.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/icefaces-ee-compat-3.2.0-ga.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/icefaces-ee-composite-3.2.0-ga.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/icefaces-ee-ext-3.2.0-ga.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/icepush-ee-3.2.0-ga.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/jcl-over-slf4j-1.7.5.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/jxl-2.6.12.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/krysalis-jCharts-1.0.0-alpha-1.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/liferay-faces-bridge-api-3.0.1-legacy-ga2.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/liferay-faces-bridge-impl-3.0.1-legacy-ga2.jar" sourcepath="/home/tibusz/.m2/repository/com/liferay/faces/liferay-faces-bridge-impl/3.0.1-legacy-ga2/liferay-faces-bridge-impl-3.0.1-legacy-ga2-sources.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/liferay-faces-util-3.0.1-legacy-ga2.jar" sourcepath="/home/tibusz/.m2/repository/com/liferay/faces/liferay-faces-util/3.0.1-legacy-ga2/liferay-faces-util-3.0.1-legacy-ga2-sources.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/log4j-over-slf4j-1.7.5.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/pojomatic-1.0.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/slf4j-api-1.7.5.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/slf4j-jdk14-1.7.5.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>icefaces-datapaginator-portlet</name>
<comment></comment>
<projects></projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments></arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0"?>
<project name="portlet" basedir="." default="deploy">
<import file="../build-common-portlet.xml" />
</project>
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.liferay.sample.portlet.model;
import java.io.Serializable;
/**
*
* @author Tibor Lipusz
*
*/
public class Car implements Serializable {
private static final long serialVersionUID = -5718553637832654631L;
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0" metadata-complete="false">
<application>
<locale-config>
<default-locale>en_US</default-locale>
</locale-config>
</application>
<managed-bean>
<managed-bean-name>viewBean</managed-bean-name>
<managed-bean-class>com.liferay.sample.portlet.beans.ViewBean</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>paginatorBean</managed-bean-name>
<managed-bean-class>com.liferay.sample.portlet.beans.PaginatorBean</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
</managed-bean>
<lifecycle>
<phase-listener>com.liferay.faces.util.lifecycle.DebugPhaseListener</phase-listener>
<phase-listener>com.liferay.faces.util.lifecycle.ViewScopePhaseListener</phase-listener>
</lifecycle>
</faces-config>
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.liferay.sample.util;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.util.portlet.PortletProps;
/**
*
* @author Tibor Lipusz
*
*/
public class IceFacesDataPaginatorPortletValues {
public static final int PAGINATOR_ROWS = GetterUtil.getInteger(
PortletProps.get("icefaces.datapaginator.portlet.paginator.rows"));
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 5.2.0//EN" "http://www.liferay.com/dtd/liferay-display_5_2_0.dtd">
<display>
<category name="category.sample">
<portlet id="icefaces-datapaginator" />
</category>
</display>
name=ICEFaces DataPaginator Sample Portlet
module-group-id=liferay
module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=MIT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_5_2_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>icefaces-datapaginator</portlet-name>
<instanceable>true</instanceable>
<ajaxable>false</ajaxable>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>Guest</role-link>
</role-mapper>
<role-mapper>
<role-name>power-user</role-name>
<role-link>Power User</role-link>
</role-mapper>
<role-mapper>
<role-name>user</role-name>
<role-link>User</role-link>
</role-mapper>
</liferay-portlet-app>
<?xml version="1.0" encoding="UTF-8" ?>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<h:head />
<h:body>
<h:form>
<h:panelGrid columns="3">
<h:outputLabel for="rowIn" value="Number of Rows (1-50):"/>
<h:inputText
id="rowIn"
value="#{paginatorBean.rows}"
required="true"
size="2"
maxlength="2">
<f:validateLongRange minimum="1" maximum="50"/>
</h:inputText>
<h:message for="rowIn"/>
</h:panelGrid>
<h:commandButton id="submitButton" value="Submit" type="submit" />
</h:form>
<ice:form>
<ice:messages></ice:messages>
<ice:outputText value="#{paginatorBean.text}" />
<ice:dataTable
id="carTable"
value="#{paginatorBean.cars}"
var="car"
rows="#{paginatorBean.rows}"
width="100%" cellspacing="1" cellpadding="5"
columnClasses="tableIdCol,tableNameCol,tableChassisCol,tableWeightCol,tableAccelCol,tableMpgCol,tableCostCol">
<ice:column>
<f:facet name="header">ID</f:facet>
#{car.id}
</ice:column>
<ice:column>
<f:facet name="header">Name</f:facet>
#{car.name}
</ice:column>
</ice:dataTable>
<!-- Now, DataPaginatorBridgeImpl supports attribute "for" only -->
<!-- <ice:dataPaginator -->
<!-- id="paginator" -->
<!-- fastStep="2" -->
<!-- for="carTable" -->
<!-- paginator="true" -->
<!-- paginatorMaxPages="3"> -->
<ice:dataPaginator
for="carTable">
<f:facet name="first">
<h:graphicImage
alt="First"
style="width: 18px; height: 18px; border: none;"
title="First"
value="/xmlhttp/css/rime/css-images/arrow-first.gif"/>
</f:facet>
<f:facet name="last">
<h:graphicImage
alt="Last"
style="width: 18px; height: 18px; border: none;"
title="Last"
value="/xmlhttp/css/rime/css-images/arrow-last.gif"/>
</f:facet>
<f:facet name="previous">
<h:graphicImage
alt="Previous"
style="width: 18px; height: 18px; border: none;"
title="Previous"
value="/xmlhttp/css/rime/css-images/arrow-previous.gif"/>
</f:facet>
<f:facet name="next">
<h:graphicImage
alt="Next"
style="width: 18px; height: 18px; border: none;"
title="Next"
value="/xmlhttp/css/rime/css-images/arrow-next.gif"/>
</f:facet>
<f:facet name="fastforward">
<h:graphicImage
alt="Fast Forward"
style="width: 18px; height: 18px; border: none;"
title="Fast Forward"
value="/xmlhttp/css/rime/css-images/arrow-ff.gif"/>
</f:facet>
<f:facet name="fastrewind">
<h:graphicImage
alt="Fast Rewind"
style="width: 18px; height: 18px; border: none;"
title="Fast Rewind"
value="/xmlhttp/css/rime/css-images/arrow-fr.gif"/>
</f:facet>
</ice:dataPaginator>
</ice:form>
</h:body>
</f:view>
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.liferay.sample.portlet.beans;
import com.liferay.sample.portlet.model.Car;
import com.liferay.sample.util.IceFacesDataPaginatorPortletValues;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Tibor Lipusz
*
*/
public class PaginatorBean implements Serializable {
private static final long serialVersionUID = 1723649154487620351L;
private int rows;
private ArrayList<Car> cars;
private String text = PaginatorBean.class.getName();
public PaginatorBean() {
this.rows = IceFacesDataPaginatorPortletValues.PAGINATOR_ROWS;
initCars();
}
public ArrayList<Car> getCars() {
return cars;
}
public int getRows() {
return rows;
}
public String getText() {
return text;
}
public void setRows(int rows) {
this.rows = rows;
}
public void setText(String text) {
this.text = text;
}
protected void initCars() {
this.cars = new ArrayList<Car>();
for (int i = 0; i < this.rows; i++) {
Car car = new Car();
car.setId(i);
car.setName("Car" + i);
cars.add(car);
}
}
}
icefaces.datapaginator.portlet.paginator.rows=30
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<portlet-name>icefaces-datapaginator</portlet-name>
<display-name>icefaces-datapaginator</display-name>
<portlet-class>org.portletfaces.bridge.GenericFacesPortlet</portlet-class>
<init-param>
<name>javax.portlet.faces.defaultViewId.view</name>
<value>/view/paginator.xhtml</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<resource-bundle>content/Language</resource-bundle>
<portlet-info>
<title>ICEFaces DataPaginator Sample Portlet</title>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
</portlet-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.uniqueResourceURLs</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.uploadDirectory</param-name>
<param-value>upload</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.compressResources</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.portlet.hiddenAttributes</param-name>
<param-value>THEME_DISPLAY</param-value>
</context-param>
<context-param>
<param-name>portlet.adjustSessionInactiveInterval</param-name>
<param-value>true</param-value>
</context-param>
<!-- Instruct Mojarra to utilize JBoss-EL instead of the EL implementation provided by the servlet container. -->
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<servlet>
<servlet-name>ResourceServlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ResourceServlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/icefaces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment