You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Christine <ch...@christine.nl> on 2009/09/21 16:32:26 UTC
custom portlet mode?
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?
dagdag
Christine
--
dagdag is just a two-character rotation of byebye.
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org
Re: custom portlet mode?
Posted by Christine <ch...@christine.nl>.
David Sean Taylor wrote:
> 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:
David, thanks.
I found an alternative by providing a parameter from my java class which
determines in the jsp what gets displayed, but having different jsp
files makes the code much cleaner.
I use it when I have different view modes for showing one entry from a
db or providing a list of entries, in different views.
dagdag
Christine
>
> <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: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
--
dagdag is just a two-character rotation of byebye.
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org
Re: custom portlet mode?
Posted by David Sean Taylor <d....@onehippo.com>.
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: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org