Presentation is loading. Please wait.

Presentation is loading. Please wait.

JSF Portlet Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.

Similar presentations


Presentation on theme: "JSF Portlet Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission."— Presentation transcript:

1 JSF Portlet Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission from Liferay, Inc.

2 Objective The goal of this tutorial is to create a Java Server Faces (JSF) Portlet within Liferay 1.Define the portlet –portlet.xml –liferay-portlet.xml 2.Define the page flow and layout –faces-config.xml 3.Create the JSP –index.jsp

3 Directory Structure Starting with Liferay version 4.2 we've made it possible to develop portlets in a deployable *.war format. This tutorial will adhere to the specs of this new feature.

4 Directory Structure 1) Go to: http://www.liferay.com/web/guest/downloads/samples 2) Download: “Sample JSF MyFaces Portlet” 3) Change the directory name to: library_jsf_portlet.war 4) This will be a template war that we modify for this tutorial. Copy library_jsf_portlet.war to …ext\portlets

5 Directory Structure Configuration files (*.xml) are located in this directory: …\ext\portlets\library_jsf_portlet.war\WEB- INF JSPs will be placed in this directory: …\ext\portlets\library_jsf_portlet.war

6 web.xml The web.xml is a standard web application descriptor file that is required by any J2EE servlet container such as Tomcat. In this case we have a *.war file that is being deployed onto Tomcat, and the web.xml file describes the portlet application. This configures our JSF implementation as well as the necessary hooks into the portal.

7 web.xml library_jsf_portlet company_id liferay.com javax.faces.STATE_SAVING_METHOD client javax.faces.application.CONFIG_FILES /WEB-INF/faces-config.xml

8 com.liferay.portal.kernel.servlet.PortletContextListener org.apache.myfaces.webapp.StartupServletContextListener library_jsf_portlet com.liferay.portal.kernel.servlet.PortletServlet portlet-class com.sample.jsfmyfaces.portlet.MyFacesGenericPortlet 0 FacesServlet javax.faces.webapp.FacesServlet 1

9 library_jsf_portlet /library_jsf_portlet/* FacesServlet /faces/* http://java.sun.com/portlet /WEB-INF/tld/liferay- portlet.tld

10 portlet.xml The portlet.xml is the portlet descriptor per the JSR-168 spec.

11 portlet.xml library_jsf_portlet org.apache.myfaces.portlet.MyFacesGenericPortlet --> com.sample.jsfmyfaces.portlet.MyFacesGenericPortlet default-view /index.jsp text/html

12 Library JSF Portlet guest power-user user

13 liferay-portlet.xml The liferay-portlet.xml contains Liferay- specific configurations

14 liferay-portlet.xml library_jsf_portlet true administrator Administrator

15 guest Guest power-user Power User user User

16 liferay-display.xml The liferay-display.xml configured display settings such as which Liferay category this portlet belongs to.

17 liferay-display.xml

18 Create the JSP The next step is to create the JSP Create index.jsp in the library directory …\ext\portlets\library_jsf_portlet.war\index.jsp Finally, enter “Simple JSF Portlet!” in index.jsp

19 index.jsp

20 Include into the build The next step is to create build file for this portlet. We must add build targets in the build.xml file. Edit build.xml here: …\ext\portlets\

21 build.xml

22 Deploy the Files to Tomcat Once you have finished modifying all of the files, deploy them to Tomcat Open up a cmd prompt –Click “Start”, “Run” and then type “cmd” Navigate to your ext\portlets directory and then type “ant deploy” …\ext\portlets>ant deploy

23 Check the Tomcat Directory Verify that the files were deployed to Tomcat Go to …\tomcat\webapps\ make sure that library_jsf_portlet was created Next, go to …\tomcat\webapps\library_jsf_portlet\ and open up index.jsp to see that it was deployed correctly

24 Check the Tomcat Directory (p.2) Go to …\tomcat\webapps\library_jsf_portlet\WE B-INF and open web.xml, portlet.xml, liferay-portlet.xml, faces-config.xml, and liferay-display.xml and check to see that the files were deployed correctly.

25 Final Steps 1.Restart Tomcat 2.Open up a new browser and type http://localhost:8080 LOGIN: test@liferay.com PASSWORD: test 3.Click Add Content  Test 4.Click Library JSF Portlet

26 Revision History Edward Shin8/28/2006Updated for Liferay 4.1.1 Jerry Niu9/5/2006-9/8/2006 Updated copyright, copy edits, liferay-portal-ext slide, final steps slide edit Jerry Niu9/27/2006 Fixed wrong tomcat deploy path James Min01/17/2007 Converted for JSF in deployable war format Ivan Cheung01/30/2007 Added dtd to xml config files


Download ppt "JSF Portlet Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission."

Similar presentations


Ads by Google