You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2009/07/08 00:55:20 UTC

[Myfaces Wiki] Update of "Running the Mojarra Samples" by MichaelFreedman

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by MichaelFreedman:
http://wiki.apache.org/myfaces/Running_the_Mojarra_Samples

New page:
It is quick and easy to get most of the samples that ship in the Mojarra binaries running not only in their regular servlet form but also exposed as portlets.   First, this guide assumes you have an installed application server running either a portlet 1.0 or portlet 2.0 portlet container.  If you don't, consider using Apache Tomcat and Pluto 1.1 or 2.0 to try these out. Once you have verified that your portal/portlet container is properly configured and running, check to see if your application server installation contains a Faces 1.2 implementation.  Java EE 5 application servers should contain Faces 1.2.  Tomcat being just a servlet/jsp implementation doesn't.  If you need a Faces 1.2 implementation do as described here. Finally, download a JSF Bridge release from the Apache !MyFaces Portlet Bridge subproject and unzip. It is recommended you use a version of the bridge that best matches the portlet container version running in your environment.

You are now ready to begin.  Download the Mojarra samples.  They are contained in the Mojarra binary release.  Unzip the download to access the samples.  Currently, Mojarra contains 6 samples: Cardemo, Components, !GuessNumber, Mojarra_Ext, Renderkits, and Webtier-Sample. This guide describes how to make the simple modifications that are needed to get the Cardemo, !GuessNumber, Mohara_Ext, and Webtier-Sample samples running in the portlet bridge and exposed as portlets.

   1. !CarDemo
          * Change to the samples/cardemo/build/jsf-cardemo directory.
          * Modify the .css link references in the following files: storeFront.jsp, finish.jsp, customerInfo.jsp, confirmChoices.jsp, chooseLocale.jsp, and carDetail.jsp.
            Change the following line from:
                   <link rel="stylesheet" type="text/css"[[BR]]
                      href="${pageContext.request.contextPath}/stylesheet.css">
            To:
                 <link rel="stylesheet" type="text/css"[[BR]]
                      href="<%=response.encodeURL(request.getContextPath() + "stylesheet.css")%>">

            Note:  In the portlet model you can't output direct URL paths.  Rather all URLs must be encoded by the portlet container to allow those containers running remotely from their consumer (portal) to encode the information properly.  The above changes work in both the portlet and servlet environments.
          *  Add into the WEB-INF directory a portlet.xml file with the following entry for the car demo portlet:
              <portlet>[[BR]]
                <description lang="EN">Mojarra Car Demo Portlet</description>[[BR]]
                <portlet-name>!CarDemo</portlet-name>[[BR]]
                <display-name lang="EN">Mojarra Car Demo</display-name>[[BR]]
                <portlet-class>javax.portlet.faces.!GenericFacesPortlet</portlet-class>[[BR]]
[[BR]]
                <init-param>[[BR]]
                  <name>javax.portlet.faces.defaultViewId.view</name>[[BR]]
                  <value>/chooseLocale.jsp</value>[[BR]]
                </init-param>[[BR]]
[[BR]]
                <supports>[[BR]]
                  <mime-type>text/html</mime-type>[[BR]]
                  <portlet-mode>view</portlet-mode>[[BR]]
                </supports>[[BR]]
                <supported-locale>en</supported-locale>[[BR]]
[[BR]]
                <portlet-info>[[BR]]
                  <title>Mojarra Car Demo</title>[[BR]]
                  <short-title>Car Demo</short-title>[[BR]]
                </portlet-info>[[BR]]
              </portlet>[[BR]]
          * If you downloaded your own copy of Faces 1.2, copy the libraries and other dependent libraries into the WEB-INF/lib directory:
            e.g.
              jsf-api.jar[[BR]]
              jsf-impl.jar[[BR]]
              jstl-1.2.jar[[BR]]
              sun-commons-beanutils.jar[[BR]]
              sun-commons-collections.jar[[BR]]
              sun-commons-digester.jar[[BR]]
              sun-commons-logging.jar[[BR]]
          * Copy the Bridge libraries into the WEB-INF/lib directory:
            e.g.
              portlet-bridge-api-1.0.0-SNAPSHOT.jar[[BR]]
              portlet-bridge-impl-1.0.0-SNAPSHOT.jar[[BR]]
          * Repackage the jsf-cardemo directory into a .war file deployable in the portlet container running in your application server.  Note:  package/deployment is portlet container specific.  Consult the documentation of your respective portlet container.

            If you are running in a Pluto 2.0 environment, you can manually package the demonstration if you add the following to the existing web.xml:
            <!-- Add portlet binding -->[[BR]]
                <servlet>[[BR]]
                   <servlet-name>!CarDemo</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>!CarDemo</param-value>[[BR]]
                   </init-param>[[BR]]
                   <load-on-startup>1</load-on-startup>[[BR]]
                </servlet>[[BR]]
            <!-- Add portlet binding -->[[BR]]
                <servlet-mapping>[[BR]]
                  <servlet-name>!CarDemo</servlet-name>[[BR]]
                  <url-pattern>/!PlutoInvoker/!CarDemo</url-pattern>[[BR]]
                </servlet-mapping>[[BR]]
   2. !GuessNumber
          * Change to the samples/guessNumber/build/jsf-guessnumber directory.
          *  Add into the WEB-INF directory a portlet.xml file with the following entry for the guess number portlet:
              <portlet>
                <description lang="EN">Mojarra Guess Number Portlet</description>
                <portlet-name>GuessNumber</portlet-name>
                <display-name lang="EN">Mojarra Guess Number</display-name>
                <portlet-class>javax.portlet.faces.!GenericFacesPortlet</portlet-class>

                <init-param>
                  <name>javax.portlet.faces.defaultViewId.view</name>
                  <value>/greeting.jsp</value>
                </init-param>

                <supports>
                  <mime-type>application/xhtml+xml</mime-type>
                  <portlet-mode>view</portlet-mode>
                </supports>

                <supported-locale>en</supported-locale>

                <portlet-info>
                  <title>Mojarra Guess Number</title>
                  <short-title>Guess Number</short-title>
                </portlet-info>
              </portlet>
          * If you downloaded your own copy of Faces 1.2, copy the libraries and other dependent libraries into the WEB-INF/lib directory:
            e.g.
                jsf-api.jar
              jsf-impl.jar
              jstl-1.2.jar
              sun-commons-beanutils.jar
              sun-commons-collections.jar
              sun-commons-digester.jar
              sun-commons-logging.jar
          * Copy the Bridge libraries into the WEB-INF/lib directory:
            e.g.
                portlet-bridge-api-1.0.0-SNAPSHOT.jar
              portlet-bridge-impl-1.0.0-SNAPSHOT.jar
          * Repackage the jsf-guessnumber directory into a .war file deployable in the portlet container running in your application server.  Note:  package/deployment is portlet container specific.  Consult the documentation of your respective portlet container.

            If you are running in a Pluto 2.0 environment, you can manually package the demonstration if you add the following to the existing web.xml:
            <!-- Add portlet binding -->
                  <servlet>
                   <servlet-name>!GuessNumber</servlet-name>
                   <servlet-class>org.apache.pluto.container.driver.PortletServlet</servlet-class>
                   <init-param>
                         <param-name>portlet-name</param-name>
                    <param-value>!GuessNumber</param-value>
                   </init-param>
                <load-on-startup>1</load-on-startup>
                </servlet>

            <!-- Add portlet binding -->
                <servlet-mapping>
                <servlet-name>!GuessNumber</servlet-name>
                <url-pattern>/!PlutoInvoker/!GuessNumber</url-pattern>
                </servlet-mapping>
   3. Mojarra_Ext
          * Change to the samples/mojarra_ext/build/mojarra_ext directory.
          *  Add into the WEB-INF directory a portlet.xml file with the following entry for the mojarra_ext portlet:
              <portlet>
                <description lang="EN">Mojarra EXT Sample</description>
                <portlet-name>EXTSample</portlet-name>
                <display-name lang="EN">Mojarra EXT Sample</display-name>
                <portlet-class>javax.portlet.faces.!GenericFacesPortlet</portlet-class>

                <init-param>
                  <name>javax.portlet.faces.defaultViewId.view</name>
                  <value>/welcome.jsp</value>
                </init-param>

                <supports>
                  <mime-type>text/html</mime-type>
                  <portlet-mode>view</portlet-mode>
                </supports>

                <supported-locale>en</supported-locale>

                <portlet-info>
                  <title>Mojarra EXT Sample</title>
                  <short-title>EXT Sample</short-title>
                </portlet-info>
              </portlet>
          * If you downloaded your own copy of Faces 1.2, copy the libraries and other dependent libraries into the WEB-INF/lib directory:
            e.g.
                jsf-api.jar
              jsf-impl.jar
              jstl-1.2.jar
              sun-commons-beanutils.jar
              sun-commons-collections.jar
              sun-commons-digester.jar
              sun-commons-logging.jar
          * Copy the Bridge libraries into the WEB-INF/lib directory:
            e.g.
                portlet-bridge-api-1.0.0-SNAPSHOT.jar
              portlet-bridge-impl-1.0.0-SNAPSHOT.jar
          * Repackage the mojarra_ext directory into a .war file deployable in the portlet container running in your application server.  Note:  package/deployment is portlet container specific.  Consult the documentation of your respective portlet container.

            If you are running in a Pluto 2.0 environment, you can manually package the demonstration if you add the following to the existing web.xml:
            <!-- Add portlet binding -->
                  <servlet>
                   <servlet-name>EXTSample</servlet-name>
                   <servlet-class>org.apache.pluto.container.driver.!PortletServlet</servlet-class>
                   <init-param>
                         <param-name>portlet-name</param-name>
                    <param-value>EXTSample</param-value>
                   </init-param>
                <load-on-startup>1</load-on-startup>
                </servlet>

            <!-- Add portlet binding -->
                <servlet-mapping>
                <servlet-name>!EXTSample</servlet-name>
                <url-pattern>/!PlutoInvoker/!EXTSample</url-pattern>
                </servlet-mapping>
   4. Webtier-Sample
          * Change to the samples/webtier-sample/build/webtier-sample directory.
          *  Add into the WEB-INF directory a portlet.xml file with the following entry for the webtier sample portlet:
              <portlet>
                <description lang="EN">Mojarra !WebTier Sample</description>
                <portlet-name>!WebTierSample</portlet-name>
                <display-name lang="EN">Mojarra !WebTier Sample</display-name>
                <portlet-class>javax.portlet.faces.!GenericFacesPortlet</portlet-class>

                <init-param>
                  <name>javax.portlet.faces.defaultViewId.view</name>
                  <value>/webtiersample.jsp</value>
                </init-param>

                <supports>
                  <mime-type>text/html</mime-type>
                  <portlet-mode>view</portlet-mode>
                </supports>

                <supported-locale>en</supported-locale>

                <portlet-info>
                  <title>Mojarra !WebTier Sample</title>
                  <short-title>!WebTier Sample</short-title>
                </portlet-info>
              </portlet>
          * If you downloaded your own copy of Faces 1.2, copy the libraries and other dependent libraries into the WEB-INF/lib directory:
            e.g.
                jsf-api.jar
              jsf-impl.jar
              jstl-1.2.jar
              sun-commons-beanutils.jar
              sun-commons-collections.jar
              sun-commons-digester.jar
              sun-commons-logging.jar
          * Copy the Bridge libraries into the WEB-INF/lib directory:
            e.g.
                portlet-bridge-api-1.0.0-SNAPSHOT.jar
              portlet-bridge-impl-1.0.0-SNAPSHOT.jar
          * Repackage the webtier-sample directory into a .war file deployable in the portlet container running in your application server.  Note:  package/deployment is portlet container specific.  Consult the documentation of your respective portlet container.

            If you are running in a Pluto 2.0 environment, you can manually package the demonstration if you add the following to the existing web.xml:
            <!-- Add portlet binding -->
                  <servlet>
                   <servlet-name>!WebTierSample</servlet-name>
                   <servlet-class>org.apache.pluto.container.driver.!PortletServlet</servlet-class>
                   <init-param>
                         <param-name>portlet-name</param-name>
                    <param-value>!WebTierSample</param-value>
                   </init-param>
                <load-on-startup>1</load-on-startup>
                </servlet>
                
            <!-- Add portlet binding -->
                <servlet-mapping>
                <servlet-name>!WebTierSample</servlet-name>
                <url-pattern>/!PlutoInvoker/!WebTierSample</url-pattern>
                </servlet-mapping>