jsf portlet liferay

26
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.

Upload: dioran

Post on 08-Nov-2015

30 views

Category:

Documents


0 download

DESCRIPTION

Jsf Portlet LIFERAY

TRANSCRIPT

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

  • ObjectiveThe goal of this tutorial is to create a Java Server Faces (JSF) Portlet within LiferayDefine the portletportlet.xmlliferay-portlet.xmlDefine the page flow and layoutfaces-config.xmlCreate the JSPindex.jsp

  • Directory StructureStarting 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.

  • Directory Structure1) Go to: http://www.liferay.com/web/guest/downloads/samples2) Download: Sample JSF MyFaces Portlet3) Change the directory name to:library_jsf_portlet.war4) This will be a template war that we modify for this tutorial.

    Copy library_jsf_portlet.war to ext\portlets

  • Directory StructureConfiguration files (*.xml) are located in this directory:\ext\portlets\library_jsf_portlet.war\WEB-INFJSPs will be placed in this directory:\ext\portlets\library_jsf_portlet.war

  • web.xmlThe 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.

  • 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

  • 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

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

  • portlet.xmlThe portlet.xml is the portlet descriptor per the JSR-168 spec.

  • portlet.xml

    library_jsf_portlet library_jsf_portlet com.sample.jsfmyfaces.portlet.MyFacesGenericPortlet default-view /index.jsp text/html

  • Library JSF Portlet Library JSF Portlet Library JSF Portlet guest power-user user

  • liferay-portlet.xmlThe liferay-portlet.xml contains Liferay-specific configurations

  • liferay-portlet.xml

    library_jsf_portlet true administrator Administrator

  • guest Guest power-user Power User user User

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

  • liferay-display.xml

  • Create the JSPThe next step is to create the JSPCreate index.jsp in the library directory\ext\portlets\library_jsf_portlet.war\index.jspFinally, enter Simple JSF Portlet! in index.jsp

  • index.jsp

  • Include into the buildThe 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\

  • build.xml

  • Deploy the Files to TomcatOnce you have finished modifying all of the files, deploy them to TomcatOpen up a cmd promptClick Start, Run and then type cmdNavigate to your ext\portlets directory and then type ant deploy\ext\portlets>ant deploy

  • Check the Tomcat DirectoryVerify that the files were deployed to TomcatGo to \tomcat\webapps\ make sure that library_jsf_portlet was createdNext, go to \tomcat\webapps\library_jsf_portlet\ and open up index.jsp to see that it was deployed correctly

  • Check the Tomcat Directory (p.2)Go to \tomcat\webapps\library_jsf_portlet\WEB-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.

  • Final StepsRestart TomcatOpen up a new browser and type http://localhost:8080 LOGIN: [email protected] PASSWORD: testClick Add Content TestClick Library JSF Portlet

  • Revision HistoryEdward Shin8/28/2006Updated for Liferay 4.1.1Jerry Niu9/5/2006-9/8/2006 Updated copyright, copy edits, liferay-portal-ext slide, finalsteps slide editJerry Niu9/27/2006 Fixed wrong tomcat deploy pathJames Min01/17/2007 Converted for JSF in deployable war formatIvan Cheung01/30/2007 Added dtd to xml config files