Differences between revisions 8 and 9
Revision 8 as of 2009-07-07 22:45:21
Size: 6870
Comment:
Revision 9 as of 2009-09-20 23:02:04
Size: 6892
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
If you don't have an existing JSF application, you can use one of the JSF samples that are part of the JSF reference implementation distribution. For information of using one of these samples, read ["Running the Mojarra Samples"]. If you don't have an existing JSF application, you can use one of the JSF samples that are part of the JSF reference implementation distribution. For information of using one of these samples, read [[Running_the_Mojarra_Samples]].
Line 9: Line 9:
 Before beginning you must have portal/portlet container installed in an application server. If you don't otherwise have one installed, consider using [http://tomcat.apache.org/download-60.cgi Apache Tomcat 6.x] along with either [http://portals.apache.org/pluto/v11/getting-started.html Pluto 1.1] (Portlet 1.0 container) or [http://portals.apache.org/pluto/v20/getting-started.html Pluto 2.0] (Portlet 2.0 container). Consult the install guides on their respective project pages for more information or refer to ["Setting up Portal Environments for Bridge"].  Before beginning you must have portal/portlet container installed in an application server. If you don't otherwise have one installed, consider using [[http://tomcat.apache.org/download-60.cgi|Apache Tomcat 6.x]] along with either [[http://portals.apache.org/pluto/v11/getting-started.html|Pluto 1.1]] (Portlet 1.0 container) or [[http://portals.apache.org/pluto/v20/getting-started.html|Pluto 2.0]] (Portlet 2.0 container). Consult the install guides on their respective project pages for more information or refer to [[Setting_up_Portal_Environments_for_Bridge]].
Line 13: Line 13:
 Before beginning you must verify whether Faces is installed as part of your server installation or not. In general, JavaEE 5 installations contain a Faces implementation. Tomcat however doesn't. If Faces is not already installed you will need to download it so its libraries can later be packaged directly into your sample .war. If you don't have a preference its recommended you use either the [http://myfaces.apache.org/download.html Apache MyFaces] implementation or the reference implementation maintained in the [https://javaserverfaces.dev.java.net/ Mojarra project].  Before beginning you must verify whether Faces is installed as part of your server installation or not. In general, JavaEE 5 installations contain a Faces implementation. Tomcat however doesn't. If Faces is not already installed you will need to download it so its libraries can later be packaged directly into your sample .war. If you don't have a preference its recommended you use either the [[http://myfaces.apache.org/download.html|Apache MyFaces]] implementation or the reference implementation maintained in the [[https://javaserverfaces.dev.java.net/|Mojarra project]].
Line 16: Line 16:
   * [http://download.java.net/javaee5/external/shared/com-sun-commons-beanutils/jars/com-sun-commons-beanutils-1.6.1.jar sun-commons-beanutils.jar]
   * [http://download.java.net/javaee5/external/shared/com-sun-commons-collections/jars/com-sun-commons-collections-2.1.jar sun-commons-collections.jar]
   * [http://download.java.net/javaee5/external/shared/com-sun-commons-digester/jars/com-sun-commons-digester-1.5.jar sun-commons-digester.jar]
   * [http://download.java.net/javaee5/external/shared/com-sun-commons-logging/jars/com-sun-commons-logging-1.0.4.jar sun-commons-logging.jar]
   * [[http://download.java.net/javaee5/external/shared/com-sun-commons-beanutils/jars/com-sun-commons-beanutils-1.6.1.jar|sun-commons-beanutils.jar]]
   * [[http://download.java.net/javaee5/external/shared/com-sun-commons-collections/jars/com-sun-commons-collections-2.1.jar|sun-commons-collections.jar]]
   * [[http://download.java.net/javaee5/external/shared/com-sun-commons-digester/jars/com-sun-commons-digester-1.5.jar|sun-commons-digester.jar]]
   * [[http://download.java.net/javaee5/external/shared/com-sun-commons-logging/jars/com-sun-commons-logging-1.0.4.jar|sun-commons-logging.jar]]
Line 21: Line 21:
 As many use cases also rely on JSP scripting its best to also check to see if the JSTL (1.2) libraries are installed. If they aren't download the [https://maven-repository.dev.java.net/repository/jstl/jars/jstl-1.2.jar JSTL library].  As many use cases also rely on JSP scripting its best to also check to see if the JSTL (1.2) libraries are installed. If they aren't download the [[https://maven-repository.dev.java.net/repository/jstl/jars/jstl-1.2.jar|JSTL library]].
Line 24: Line 24:
 Finally, you will also need the [http://myfaces.apache.org/portlet-bridge/download.html Portlet Bridge libraries] as this will also be packaged directly into your sample .war.  Finally, you will also need the [[http://myfaces.apache.org/portlet-bridge/download.html|Portlet Bridge libraries]] as this will also be packaged directly into your sample .war.
Line 30: Line 30:
     <portlet>[[BR]]
        <portlet-name>MyJSFAppExposedAsAPortlet</portlet-name>[[BR]]
        <portlet-class>javax.portlet.faces.!GenericFacesPortlet</portlet-class>[[BR]]
        <expiration-cache>0</expiration-cache>[[BR]]
     <portlet><<BR>>
        <portlet-name>MyJSFAppExposedAsAPortlet</portlet-name><<BR>>
        <portlet-class>javax.portlet.faces.!GenericFacesPortlet</portlet-class><<BR>>
        <expiration-cache>0</expiration-cache><<BR>>
Line 35: Line 35:
        <init-param>[[BR]]
          <name>javax.portlet.faces.defaultViewId.view</name>[[BR]]
          <value>/myInitialView.jsp</value>[[BR]]
        </init-param>[[BR]]
        <init-param><<BR>>
          <name>javax.portlet.faces.defaultViewId.view</name><<BR>>
          <value>/myInitialView.jsp</value><<BR>>
        </init-param><<BR>>
Line 40: Line 40:
       <supports>[[BR]]
          <mime-type>text/html</mime-type>[[BR]]
       </supports>[[BR]]
       <portlet-info>[[BR]]
          <title>MyJSFAppExposedAsAPortlet</title>[[BR]]
          <short-title>MyJSFAppExposedAsAPortlet</short-title>[[BR]]
       </portlet-info>[[BR]]
       <supports><<BR>>
          <mime-type>text/html</mime-type><<BR>>
       </supports><<BR>>
       <portlet-info><<BR>>
          <title>MyJSFAppExposedAsAPortlet</title><<BR>>
          <short-title>MyJSFAppExposedAsAPortlet</short-title><<BR>>
       </portlet-info><<BR>>
Line 55: Line 55:
    <servlet-name>''portlet-name''</servlet-name>[[BR]]
           <servlet-class>org.apache.pluto.container.driver.!PortletServlet</servlet-class>[[BR]]
       <init-param>[[BR]]
          <param-name>portlet-name</param-name>[[BR]]
  <param-value>''portlet-name''</param-value>[[BR]]
    </init-param>[[BR]]
    <load-on-startup>1</load-on-startup>[[BR]]
 </servlet>[[BR]]
    <servlet-name>''portlet-name''</servlet-name><<BR>>
           <servlet-class>org.apache.pluto.container.driver.!PortletServlet</servlet-class><<BR>>
       <init-param><<BR>>
          <param-name>portlet-name</param-name><<BR>>
  <param-value>''portlet-name''</param-value><<BR>>
    </init-param><<BR>>
    <load-on-startup>1</load-on-startup><<BR>>
 </servlet><<BR>>
Line 64: Line 64:
       <servlet-mapping>[[BR]]
 <servlet-name>''portlet-name''</servlet-name>[[BR]]
 <url-pattern>/!PlutoInvoker/''portlet-name''</url-pattern>[[BR]]
       <servlet-mapping><<BR>>
 <servlet-name>''portlet-name''</servlet-name><<BR>>
 <url-pattern>/!PlutoInvoker/''portlet-name''</url-pattern><<BR>>

Introduction

One of the first things one wants to do with a new technology is to see it in action. This guide provides information so you can quickly take an existing JSF application, get it packaged with the bridge and deployed and running as a portlet. The procedure for using the Portlet 1.0 Bridge is the same as the Portlet 2.0 Bridge except the Portlet 2.0 Bridge can only run in a Portlet 2.0 container. Its recommended you match the version of the bridge with the version of the portlet container you are running.

If you don't have an existing JSF application, you can use one of the JSF samples that are part of the JSF reference implementation distribution. For information of using one of these samples, read Running_the_Mojarra_Samples.

Assumptions

Application Server

  • Before beginning you must have portal/portlet container installed in an application server. If you don't otherwise have one installed, consider using Apache Tomcat 6.x along with either Pluto 1.1 (Portlet 1.0 container) or Pluto 2.0 (Portlet 2.0 container). Consult the install guides on their respective project pages for more information or refer to Setting_up_Portal_Environments_for_Bridge.

Faces

  • Before beginning you must verify whether Faces is installed as part of your server installation or not. In general, JavaEE 5 installations contain a Faces implementation. Tomcat however doesn't. If Faces is not already installed you will need to download it so its libraries can later be packaged directly into your sample .war. If you don't have a preference its recommended you use either the Apache MyFaces implementation or the reference implementation maintained in the Mojarra project. Note: If you are using the Mojarra implementation you will need to download a couple of dependent common libraries:

    As many use cases also rely on JSP scripting its best to also check to see if the JSTL (1.2) libraries are installed. If they aren't download the JSTL library.

Portlet Bridge

Convert your JSF Web Application into a Portlet Application

  1. If not already in a suitable desconstructed form, Explode/Unzip your application into the filesystem.
  2. Add a portlet.xml to the application's WEB-INF directory. The version of your portlet.xml should coincide with the version of the portlet container. Within the portlet.xml add a new portlet tag entry for each portlet you want to expose from your application. Use javax.portlet.faces.GenericFacesPortlet as the value for the <portlet-class> tag. Add a portlet <init-param> for each portlet mode that you want bound to a default JSF view. This tells the bridge what JSF target to render for the specific mode when the incoming request isn't already encoded with a JSF target, e.g. the initial render. The <name> value for the <init-param> is javax.portlet.faces.defaultViewId.<portlet-mode> where <portlet-mode> is the name of the mode defining the default JSF target mapping. The <value> value for the <init-param> is the target JSF view. This value has the same form as used/referenced in a faces-config.xml navigation rule. I.e. its not the form that is servlet mapped rather the target result of that mapping.

    • <portlet>

      • <portlet-name>MyJSFAppExposedAsAPortlet</portlet-name>
        <portlet-class>javax.portlet.faces.GenericFacesPortlet</portlet-class>
        <expiration-cache>0</expiration-cache>

        <init-param>

        • <name>javax.portlet.faces.defaultViewId.view</name>
          <value>/myInitialView.jsp</value>

        </init-param>

      • <supports>

        • <mime-type>text/html</mime-type>

        </supports>
        <portlet-info>

        • <title>MyJSFAppExposedAsAPortlet</title>
          <short-title>MyJSFAppExposedAsAPortlet</short-title>

        </portlet-info>

    • </portlet>

  3. Add the portlet bridge jar files to your WEB-INF/lib directory. (Both the -api and -impl jars).
  4. If your installation doesn't contain a Faces implementation, add the jars for the version you downloaded (plus any dependent libraries) to your WEB-INF/lib directory.
  5. If pages rely on JSTL and the library isn't already installed, add the jar to your WEB-INF/lib directory.
  6. Repackage the above into a new .war file.
  7. (re)Deploy the .war in your server. Note: portlet deployment is server dependent. Some servers can deploy a generic Portlet Application (.war) as we constructed above. Other servers require a manual or tool driven process to repackage a generic application for deployment in its environment. Consult the documentation for the portlet container running in your environment. For example, Pluto requires additional deployment information in the web.xml. This can be added manually or by adding rules in build scripts. Specifically, for each portlet in the portlet.xml Pluto requires a corresponding <serlvet> and <servlet-mapping> entry in the web.xml where portlet-name is the name used to identify the portlet in the portlet.xml (<portlet-name> tag):

    • <servlet>

      • <servlet-name>portlet-name</servlet-name>
        <servlet-class>org.apache.pluto.container.driver.PortletServlet</servlet-class>
        <init-param>

        • <param-name>portlet-name</param-name>
          <param-value>portlet-name</param-value>

        </init-param>
        <load-on-startup>1</load-on-startup>

      • </servlet>

      <servlet-mapping>

      • <servlet-name>portlet-name</servlet-name>
        <url-pattern>/!PlutoInvoker/portlet-name</url-pattern>

      </servlet-mapping>

Getting_started_with_the_Bridge (last edited 2009-09-20 23:02:04 by localhost)