File | New Project
- Categories: Java Web
- Projects: Web Application
- Project Name: ICEfacesLiferay001
- Server: Liferay 5.2.3 (Tomcat 6.0.18)
- Java EE Version: Java EE 5
- Context Path: /ICEfacesLiferay001
- Select the frameworks you want to use in your web application.
- Checked: ICEfaces
- ICEfaces Configuration...
- Checked: Validate XML
- Checked: Synchronous Update
- Checked: Concurrent DOM View
- Un-Checked: welcomeICEfaces.jspx
- Un-Checked: welcomeICEfaces.xhtml (Facelets Only)
Create JSF Portlet Page
Projects (tab) | Expand ICEfacesLiferay001 | Right Click WebPages | New | Other
- Categories: Java Server Faces
- File Types: JSF JSP Page
- JSP File Name: MyIcePortlet_view
- Project: ICEfacesLiferay001
- Location: WebPages
- Folder: (blank)
- Created File: (automatically populated)
- Options: JSP Document (XML Syntax)
A new file called MyIcePortlet_view.jspx will be created. Replace the entire contents of this file with the following. Then save the new file.
<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<html>
<head>
<title>VIEW: My ICEfaces Portlet</title>
</head>
<body>
<ice:portlet>
<ice:form id="iceform">
VIEW: Hello World ICEfaces Portlet
</ice:form>
</ice:portlet>
</body>
</html>
</f:view>
Create portlet.xml
Projects (tab) | Expand ICEfacesLiferay001 | Expand Web Pages | Expand WEB-INF | Right Click WebPages | New | Other
- Categories: XML
- File Types: XML Document
- File Name: portlet
- Project: ICEfacesLiferay001
- Folder: web/WEB-INF
- Created File: (automatically populated)
- Selected: Well-formed Document
A new file called portlet.xml will be created. Replace the entire contents of this file with the following. Then save the new file.
<?xml version="1.0"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
<portlet>
<portlet-name>MyIcePortlet</portlet-name>
<display-name>MyIcePortlet</display-name>
<portlet-class>com.icesoft.faces.webapp.http.portlet.MainPortlet</portlet-class>
<init-param>
<name>com.icesoft.faces.portlet.viewPageURL</name>
<value>/MyIcePortlet_view.iface</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<portlet-info>
<title>ICEfaces: MyIcePortlet</title>
<short-title>MyIcePortlet</short-title>
<keywords>ICEfaces My Ice Portlet</keywords>
</portlet-info>
</portlet>
</portlet-app>
Update liferay-portlet.xml
Projects (tab) | Expand ICEfacesLiferay001 | Expand Web Pages | Expand WEB-INF | Double Click liferay-portlet.xml
Edit liferay-portlet.xml and add the the <portlet> element as shown in bold, below. Then save the file.
<?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>MyIcePortlet</portlet-name>
<instanceable>true</instanceable>
<render-weight>1</render-weight>
<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>
Update liferay-display.xml
Projects (tab) | Expand ICEfacesLiferay001 | Expand Web Pages | Expand WEB-INF | Double Click liferay-display.xml
Edit liferay-display.xml and update the the <category> element as shown in bold, below. Then save the file.
<?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="ICEfaces Portlets">
<portlet id="MyIcePortlet"/>
</category>
</display>
Update web.xml
Projects (tab) | Expand ICEfacesLiferay001 | Expand Web Pages | Expand WEB-INF | Double Click web.xml
Edit web.xml. Search for <servlet-name>Faces Servlet</servlet-name> that has the element <url-pattern>/faces/*</url-pattern>. Replace <url-pattern>/faces/*</url-pattern> with <url-pattern>*.jspx</url-pattern> as shown in bold, below. Then save the file.
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
Test
In NetBeans...
- Click on the triangular green Run Main Project icon below the menu bar.
- A browser window will automatically open. If the window does not open, go to http://localhost:8080/web/guest/ in your web browesr.
In the web browser...
- Click on the Login as bruno link in the Current Users portlet.
- Hover over Welcome Bruno Admin! at the top right.
- Click Add Application.
- The Add Application portlet will appear.
- Click on ICEfaces Portlets in the The Add Application portlet to expand the node.
- Click Add next to ICEfaces: MyIcePortlet.
- The ICEfaces: MyIcePortlet will appear.
In the web browser...
- Verify that the portlet is displayed.
- Click the Remove (X) icon at the top right of the ICEfaces: MyIcePortlet portlet.
- Are you sure you want to remove this component? OK
- Hover over Welcome Bruno Admin! at the top right.
- Click Sign Out.
In NetBeans...
- On the Output panel, click the Stop Server (X) icon.