Differences between revisions 12 and 13
Revision 12 as of 2006-07-21 02:12:13
Size: 1841
Editor: Stormspire
Comment:
Revision 13 as of 2009-09-20 23:01:41
Size: 1843
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
`<!-- You must use this Portlet impl class -->`[[BR]]
`<portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>`[[BR]]
[[BR]][[BR]]

`<!-- The "home page" of your JSF application -->`[[BR]]
`<!-- This is a required param. -->`[[BR]]
`<init-param>`[[BR]]

` <name>default-view</name>`[[BR]]
` <value>/some_view_id_from_faces-config</value>`[[BR]]
`</init-param>`[[BR]]
[[BR]][[BR]]

`<!-- A class name that implements org.apache.myfaces.portlet.DefaultViewSelector -->`[[BR]]
`<!-- This optional param is used if your want to choose different default views -->`[[BR]]
`<!-- based on some condition. You still must specify default-view above, but -->`[[BR]]
`<!-- this impl will take precedence. -->`[[BR]]
`<init-param>`[[BR]]

` <name>default-view-selector</name>`[[BR]]
` <value>com.foo.MyViewSelector</value>`[[BR]]
`</init-param>`[[BR]]
`<!-- You must use this Portlet impl class -->`<<BR>>
`<portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>`<<BR>>
<<BR>><<BR>>

`<!-- The "home page" of your JSF application -->`<<BR>>
`<!-- This is a required param. -->`<<BR>>
`<init-param>`<<BR>>

` <name>default-view</name>`<<BR>>
` <value>/some_view_id_from_faces-config</value>`<<BR>>
`</init-param>`<<BR>>
<<BR>><<BR>>

`<!-- A class name that implements org.apache.myfaces.portlet.DefaultViewSelector -->`<<BR>>
`<!-- This optional param is used if your want to choose different default views -->`<<BR>>
`<!-- based on some condition. You still must specify default-view above, but -->`<<BR>>
`<!-- this impl will take precedence. -->`<<BR>>
`<init-param>`<<BR>>

` <name>default-view-selector</name>`<<BR>>
` <value>com.foo.MyViewSelector</value>`<<BR>>
`</init-param>`<<BR>>
Line 36: Line 36:
reference: [http://portals.apache.org/bridges/multiproject/jsf-demo/index.html] reference: [[http://portals.apache.org/bridges/multiproject/jsf-demo/index.html]]

How to create a JSF Portlet using MyFaces:

Option 1: MyFacesGenericPortlet

  1. Make sure your JSF MyFaces application runs as a stand-alone servlet.

  2. Remove any redirects from your faces-config.xml. Portlets can not handle these.
  3. Create a Portlet WAR as per the instructions for your Portlet container. Make sure it contains everything that was included in step 1.
  4. Update your portlet.xml file as follows:

<!-- You must use this Portlet impl class -->
<portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>


<!-- The "home page" of your JSF application -->
<!-- This is a required param.               -->
<init-param>
   <name>default-view</name>
   <value>/some_view_id_from_faces-config</value>
</init-param>


<!-- A class name that implements org.apache.myfaces.portlet.DefaultViewSelector -->
<!-- This optional param is used if your want to choose different default views  -->
<!-- based on some condition.  You still must specify default-view above, but    -->
<!-- this impl will take precedence.                                             -->
<init-param>
   <name>default-view-selector</name>
   <value>com.foo.MyViewSelector</value>
</init-param>

Option 2: Apache Portal Bridge

  1. same steps as above, but replace org.apache.myfaces.portlet.MyFacesGenericPortlet with org.apache.portals.bridges.jsf.FacesPortlet,

  2. put portal bridge jar files inside /WEB-INF/lib.

Caution: Option 1 can work inside/outside portlet, and Option 2 can't work standalone, unless remove the bridge jar. I think it is a bug.

reference: http://portals.apache.org/bridges/multiproject/jsf-demo/index.html

CreatingJSFPortlets (last edited 2009-09-20 23:01:41 by localhost)