Micha Kops avatar Micha Kops committed d383090

JSF 2 Portlet Bridge Integration added

Comments (0)

Files changed (8)

 <?xml version="1.0" encoding="UTF-8"?>
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.hascode.tutorial</groupId>
 	<artifactId>liferay-portlet-tutorial</artifactId>
 			<version>2.0</version>
 			<scope>provided</scope>
 		</dependency>
+		<dependency>
+			<groupId>org.portletfaces</groupId>
+			<artifactId>portletfaces-bridge</artifactId>
+			<version>2.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.el</groupId>
+			<artifactId>el-api</artifactId>
+			<version>1.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.faces</groupId>
+			<artifactId>jsf-api</artifactId>
+			<version>2.1.1-b03</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.faces</groupId>
+			<artifactId>jsf-impl</artifactId>
+			<version>2.1.1-b03</version>
+		</dependency>
 	</dependencies>
+	<repositories>
+		<repository>
+			<id>maven2-repository.dev.java.net</id>
+			<url>http://download.java.net/maven/2</url>
+		</repository>
+		<repository>
+			<id>maven2-repository-portletfaces.org</id>
+			<url>http://repo.portletfaces.org/mvn/maven2</url>
+		</repository>
+	</repositories>
 	<properties>
 		<liferay.auto.deploy.dir>../bundles/liferay-portal-6.0/deploy</liferay.auto.deploy.dir>
 		<liferay.version>6.0.6</liferay.version>

src/main/java/com/hascode/tutorial/jsf/UserBean.java

+package com.hascode.tutorial.jsf;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+
+@ManagedBean
+@ViewScoped
+public class UserBean {
+	public String[] getUserNames() {
+		return new String[]{"adam", "barry", "douglas", "ethan"};
+	}
+}

src/main/webapp/WEB-INF/faces-config.xml

+<?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">
+
+	<application>
+		<message-bundle>i18nFaces</message-bundle>
+		<resource-bundle>
+			<base-name>i18n</base-name>
+			<var>i18n</var>
+		</resource-bundle>
+	</application>
+	<!-- <lifecycle>
+		<phase-listener>org.portletfaces.example.util.DebugPhaseListener</phase-listener>
+	</lifecycle> -->
+	<navigation-rule>
+		<from-view-id>/xhtml/viewMode.xhtml</from-view-id>
+		<navigation-case>
+			<from-outcome>success</from-outcome>
+			<to-view-id>/xhtml/viewMode.xhtml</to-view-id>
+		</navigation-case>
+	</navigation-rule>
+</faces-config>

src/main/webapp/WEB-INF/portlet.xml

 			<keywords>hascode-annotation-example</keywords>
 		</portlet-info>
 	</portlet>
+	
+	<portlet>
+		<portlet-name>1</portlet-name>
+		<display-name>JSF2-Portlet-Bridge</display-name>
+		<portlet-class>org.portletfaces.bridge.GenericFacesPortlet</portlet-class>
+		<init-param>
+			<name>javax.portlet.faces.defaultViewId.view</name>
+			<value>/xhtml/viewMode.xhtml</value>
+		</init-param>
+		<init-param>
+			<name>javax.portlet.faces.defaultViewId.edit</name>
+			<value>/xhtml/editMode.xhtml</value>
+		</init-param>
+		<init-param>
+			<name>javax.portlet.faces.defaultViewId.help</name>
+			<value>/xhtml/helpMode.xhtml</value>
+		</init-param>
+		<supports>
+			<mime-type>text/html</mime-type>
+			<portlet-mode>view</portlet-mode>
+			<portlet-mode>edit</portlet-mode>
+			<portlet-mode>help</portlet-mode>
+		</supports>
+		<portlet-info>
+			<title>JSF2-Portlet-Bridge</title>
+			<short-title>JSF2-Portlet-Bridge</short-title>
+			<keywords>JSF2-Portlet-Bridge</keywords>
+		</portlet-info>
+	</portlet>
 
 	<event-definition>
 		<qname xmlns:hc="http://www.hascode.com/portlet">hc:message</qname>

src/main/webapp/WEB-INF/web.xml

 <?xml version="1.0" encoding="UTF-8"?>
 
-<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+	<servlet>
+		<servlet-name>Faces Servlet</servlet-name>
+		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
 </web-app>

src/main/webapp/xhtml/editMode.xhtml

+<?xml version="1.0" encoding="UTF-8"?>
+<f:view xmlns:f="http://java.sun.com/jsf/core"
+	xmlns:h="http://java.sun.com/jsf/html"
+	xmlns:ui="http://java.sun.com/jsf/facelets">
+	<h:head />
+	<h:body>
+		<h:outputText value="EDIT" />
+	</h:body>
+</f:view>

src/main/webapp/xhtml/helpMode.xhtml

+<?xml version="1.0" encoding="UTF-8"?>
+<f:view xmlns:f="http://java.sun.com/jsf/core"
+	xmlns:h="http://java.sun.com/jsf/html"
+	xmlns:ui="http://java.sun.com/jsf/facelets">
+	<h:head />
+	<h:body>
+		<h:outputText value="HELP" />
+	</h:body>
+</f:view>

src/main/webapp/xhtml/viewMode.xhtml

+<?xml version="1.0" encoding="UTF-8"?>
+<f:view xmlns:f="http://java.sun.com/jsf/core"
+	xmlns:h="http://java.sun.com/jsf/html"
+	xmlns:ui="http://java.sun.com/jsf/facelets">
+	<h:head />
+	<h:body>
+		<h:outputText value="VIEW" />
+		<ul>
+			<ui:repeat value="${userBean.userNames}" var="userName">
+				<li><h:outputText value="${userName}" /></li>
+			</ui:repeat>
+		</ul>
+	</h:body>
+</f:view>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.