JSF Portlet Bridge - Edit Functionality
The jsfportlet bridge that is shipped in Sun Java Portal Server 7.0 supports all three Portlet Modes(i.e VIEW, EDIT and HELP). In the portlet.xml of the jsf portlet web application, you need to set as follows
VIEW mode:
<init-param>
<description>Portlet init page</description>
<name>com.sun.faces.portlet.INIT_VIEW</name>
<value>/view.jsp</value>
</init-param>
EDIT mode:
<init-param>
<description>Portlet edit page</description>
<name>com.sun.faces.portlet.INIT_EDIT</name>
<value>/edit.jsp</value>
</init-param>
HELP mode:
<init-param>
<description>Portlet help page</description>
<name>com.sun.faces.portlet.INIT_HELP</name>
<value>/help.jsp</value>
</init-param>
When the page is in VIEW mode, the portlet window decoration has buttons for Edit and Help. Clicking Edit brings up the page that is tagged with com.sun.faces.portlet.INIT_EDIT(edit.jsp from the snippet above). This page is a maximized page with no decorations.
Now the question is how to go back to the View page from the Edit page as there are no window decorations to go back to the view page.
There are two states upon exiting the EDIT mode page and returning to the initial VIEW mode page.
* State 1. The user is exiting and does NOT want to save any changes. (eg: using "save" button)
* State 2. The user is exiting and does want to save any changes.(eg: using "cancel" button)
The Portlet developer must in the JSF navigation should specify the page tagged INIT_VIEW for state 1 & 2. i.e The navigation rule should be written such that when the EDIT is successful/cancelled, points to the first view page.(i.e the page tagged INIT_VIEW).
Example:
<navigation-rule>
<from-view-id>/edit.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/view.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/edit.jsp</from-view-id>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/view.jsp</to-view-id>
</navigation-case>
</navigation-rule>
VIEW mode:
<init-param>
<description>Portlet init page</description>
<name>com.sun.faces.portlet.INIT_VIEW</name>
<value>/view.jsp</value>
</init-param>
EDIT mode:
<init-param>
<description>Portlet edit page</description>
<name>com.sun.faces.portlet.INIT_EDIT</name>
<value>/edit.jsp</value>
</init-param>
HELP mode:
<init-param>
<description>Portlet help page</description>
<name>com.sun.faces.portlet.INIT_HELP</name>
<value>/help.jsp</value>
</init-param>
When the page is in VIEW mode, the portlet window decoration has buttons for Edit and Help. Clicking Edit brings up the page that is tagged with com.sun.faces.portlet.INIT_EDIT(edit.jsp from the snippet above). This page is a maximized page with no decorations.
Now the question is how to go back to the View page from the Edit page as there are no window decorations to go back to the view page.
There are two states upon exiting the EDIT mode page and returning to the initial VIEW mode page.
* State 1. The user is exiting and does NOT want to save any changes. (eg: using "save" button)
* State 2. The user is exiting and does want to save any changes.(eg: using "cancel" button)
The Portlet developer must in the JSF navigation should specify the page tagged INIT_VIEW for state 1 & 2. i.e The navigation rule should be written such that when the EDIT is successful/cancelled, points to the first view page.(i.e the page tagged INIT_VIEW).
Example:
<navigation-rule>
<from-view-id>/edit.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/view.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/edit.jsp</from-view-id>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/view.jsp</to-view-id>
</navigation-case>
</navigation-rule>