Author: mmcallis
Date: 2008-02-17 23:12:51 -0500 (Sun, 17 Feb 2008)
New Revision: 10010
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/tutorials.xml
Log:
5.2.4. An example Apache MyFaces JSF Portlet
revising to make more consistent with 5.2.1. Deploying your first Portlet
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/tutorials.xml
===================================================================
---
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/tutorials.xml 2008-02-18
02:28:34 UTC (rev 10009)
+++
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/tutorials.xml 2008-02-18
04:12:51 UTC (rev 10010)
@@ -1084,6 +1084,18 @@
</para>
</listitem>
</varlistentry>
+<varlistentry><term><screen><![CDATA[
+<supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+</supports>]]></screen></term>
+ <listitem>
+ <para>
+ The <computeroutput><supports></computeroutput>
element allows you to declare all the markup types your portlet supports in the
<literal>render</literal> method. This is accomplished via the
+ <computeroutput><mime-type></computeroutput> element,
which is required for every portlet. The declared MIME types must match the capability of
the portlet. As well, it allows you to pair which modes and window states are supported
for each markup type. All portlets must support the VIEW portlet mode, so this does not
have to be declared. Use
<computeroutput><mime-type></computeroutput> to define which
markup type your portlet supports, which in this example, is
<computeroutput>text/html</computeroutput>. This section tells the portal that
it will only output text and HTML, and that it only supports the
<computeroutput>VIEW</computeroutput> mode.
+ </para>
+</listitem>
+</varlistentry>
</variablelist>
</para>
<para>
@@ -1343,7 +1355,7 @@
</mediaobject>
</para>
<para>
- To create the <filename>WEB-INF/</filename> and
<filename>META-INF/</filename> directories, extract the
<filename>helloworldjsfmyfacesportlet.war</filename> file. The
<filename>WEB-INF/lib/</filename> directory must contain the MyFaces
libraries, along with the dependent libraries.
+ To create the <filename>WEB-INF/</filename> and
<filename>META-INF/</filename> directories, extract the
<filename>helloworldjsfmyfacesportlet.war</filename> file. The
<filename>WEB-INF/lib/</filename> directory must contain the Apache MyFaces
libraries, along with the dependent libraries.
</para>
</sect3>
<sect3>
@@ -1387,11 +1399,7 @@
</screen></term>
<listitem>
<para>
- Here we specify that MyFacesGenericPortlet will handle all requests/responses from our
- users. There is therefore no need to develop a specific portlet class, MyFaces
- providing a generic implementation bridging the JSF and portlet worlds.
- <note><para>If you wanted to add more functionality to your JSF portlet,
not included in the
- MyFacesGenericPortlet, you could sublass it and create your own
Class.</para></note>
+ This specifies that the
<computeroutput>org.apache.myfaces.portlet.MyFacesGenericPortlet</computeroutput>
handles all requests and responses from the users. Therefore, there is no need to develop
a specific portlet class, as Apache MyFaces provides a generic implementation which
bridges the JSF and portlet worlds.
</para>
</listitem>
</varlistentry>
@@ -1403,14 +1411,33 @@
</screen></term>
<listitem>
<para>
- We need to initialize the portlet with a default view page for it to render, much like
- a welcome page:
+ You must initialize the portlet with a default page to render, similar to a welcome
page.
</para>
</listitem>
</varlistentry>
+<varlistentry><term><screen><![CDATA[
+<supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+</supports>]]></screen></term>
+ <listitem>
+ <para>
+ The <computeroutput><supports></computeroutput>
element allows you to declare all the markup types your portlet supports in the
<literal>render</literal> method. This is accomplished via the
+ <computeroutput><mime-type></computeroutput> element,
which is required for every portlet. The declared MIME types must match the capability of
the portlet. As well, it allows you to pair which modes and window states are supported
for each markup type. All portlets must support the VIEW portlet mode, so this does not
have to be declared. Use
<computeroutput><mime-type></computeroutput> to define which
markup type your portlet supports, which in this example, is
<computeroutput>text/html</computeroutput>. This section tells the portal that
it will only output text and HTML, and that it only supports the
<computeroutput>VIEW</computeroutput> mode.
+ </para>
+</listitem>
+</varlistentry>
</variablelist>
</para>
<para>
+ <note>
+ <title>Adding Functionality to a Apache MyFaces JSF Porlet</title>
+ <para>
+ To add functionality to a Apache MyFaces JSF Porlet, sub-class it and create your own
class.
+ </para>
+ </note>
+</para>
+<para>
The following is an example
<filename>HelloWorldJSFMyFaces42Portlet/WEB-INF/faces-config.xml</filename>
file:
</para>
<para>
@@ -1433,48 +1460,26 @@
</navigation-case>
</navigation-rule>
</faces-config>]]>
-
-
- <para><literal>web.xml</literal>
-<programlisting><![CDATA[<context-param>
+</screen>
+</para>
+ <para>
+ Without the <filename>faces-config.xml</filename> file, the application
would work the same outside of the portlet as it would inside a portlet container. In this
example, a basic user bean,
<computeroutput><managed-bean-name>user</managed-bean-name></computeroutput>,
and a navigation rule are defined, which handle the submission of the original form in the
<filename>HelloWorldJSFMyFaces42Portlet/WEB-INF/jsp/index.jsp</filename>
file.
+ </para>
+<para>
+ The following is an example of the Faces Servlet section from the
HelloWorldJSFMyFaces42Portlet/WEB-INF/web.xml file:
+</para>
+<para>
+<screen><![CDATA[
+<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
-</context-param>]]></programlisting>
- We need this extra parameter to let the application server know
that the package embeds its own libraries.
- It will avoid collision with the Sun RI JSF libraries bundled
with JBoss AS.
- More details on this procedure can be found at <ulink
-
url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossFaces">ht...;.
- </para>
- </listitem>
- <listitem>
- <para><literal>faces-config.xml</literal>
-<programlisting><![CDATA[<?xml version="1.0"?>
-<!DOCTYPE faces-config PUBLIC
- "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
-<faces-config>
- <managed-bean>
- <description>Basic UserBean</description>
- <managed-bean-name>user</managed-bean-name>
-
<managed-bean-class>org.jboss.portlet.hello.bean.User</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- </managed-bean>
- <navigation-rule>
- <navigation-case>
- <from-outcome>done</from-outcome>
- <to-view-id>/WEB-INF/jsp/result.jsp</to-view-id>
- </navigation-case>
- </navigation-rule>
-</faces-config>]]></programlisting>
- There is nothing special about the
<literal>faces-config.xml</literal> file included here. This
- application would work just as well outside of a portlet as it
would inside a portlet container.
- In the above lines, we define a basic
<literal>User</literal> Bean and a navigation rule to
- handle the submittal of the original form on
<literal>index.jsp</literal>.
- </para>
- </listitem>
- </itemizedlist>
- </para>
- </sect3>
+</context-param>]]>
+</screen>
+</para>
+<para>
+ These extra parameters let the application server know that the portlet embeds its own
libraries. This avoids collision with the Sun JSF RI libraries bundled with JBoss AS And
JBoss EAP. For further details, refer to the <ulink
url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossFaces">Ap... MyFaces page
on the JBoss Wiki</ulink>.
+</para>
+</sect3>
<sect3>
<title>Building your Apache MyFaces JSF Porlet</title>
<para>If you have downloaded the sample, you can execute the build.xml
with ant or inside your IDE.