On Sep 21, 2009, at 7:32 AM, Christine wrote:
Can I define custom portlet modes? Like for a portlet that has a
number of different views? Or if not, how do I switch from one jsp
to another within a portlet?
Best to look at existing examples provided in the j2-admin portlet
application or demo application that we provide. For example, if you
look at the j2-admin portlet.xml, we define
<custom-portlet-mode>
<description>a Custom Edit_defaults Mode</description>
<portlet-mode>edit_defaults</portlet-mode>
</custom-portlet-mode>
and then use it in the portlet definition:
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
<portlet-mode>EDIT</portlet-mode>
<!-- support custom edit_defaults mode -->
<portlet-mode>edit_defaults</portlet-mode>
</supports>
In your portlet, handle the doDispatch:
protected void doDispatch(RenderRequest request, RenderResponse
response) throws PortletException, IOException
{
if ( !request.getWindowState().equals(WindowState.MINIMIZED))
{
PortletMode curMode = request.getPortletMode();
if (JetspeedActions.EDIT_DEFAULTS_MODE.equals(curMode))
{
doEdit(request, response); // or do something else...
}
else
{
super.doDispatch(request, response);
}
}
}
The Portlet API punts when it comes to adding any additional API
support for handling navigation between pages under the same view. Its
viewed as the job of our MVC framework. Spring has a nice solution
called Spring Web Flow that works in portlets:
http://www.springsource.org/webflow
If you don't need all of that abstraction, you can simply navigate
with for example the GenericServletPortlet, and setting the view page:
request.setAttribute(PARAM_VIEW_PAGE, "/WEB-INF/view/
mypage.jsp");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]