De : Wei Guan [mailto:[EMAIL PROTECTED]]
>
> First, I would like to say: Great job.
>
> I am still puzzling on how to build highly-interactive
> portlet. Here is a user case:
> 1) the default template is page1.vm rendering default data
> prepared by buildNormalConent of Action1.java
> 2) on page1.vm, there are couple of links, each link will
> result an action, generate different data and need diifferent
> templates to render. For example, there is a link "link1" on page1.vm:
> page1.vm ---link1--->method in action1---->page2.vm.
>
> I think this is the sequence in JetSpeed
> 1) action1.buildNormalContent ---> page1.vm
> 2) --->link1--->method in action1
> -->action1.buildNormalContent--->action1.setTempate(page2.vm)-
> -->page2.vm.
>
> I am looking for a solution like this.
> 1) action1.buildNormalContent ---> page1.vm
> 2) --->link1--->method in action2
> -->action2.buildNormalContent--->action2.setTempate(page2.vm)-
> -->page2.vm.
>
This is not possible in the default VelocityPortlet but it's very easy
to implement.
For example:
Assumption: you can define a new non-conflicting parameter name
that will handle the state of your portlet, let's say "pstate".
1- Update your portlet Regsitry definition to have:
<parameter name="action" value="MyDefaultPortletAction" />
<parameter name="template" value="MyDefaultTemplate.vm" />
<parameter name="action.update" value="MyActionInStateUpdate" />
<parameter name="template.update" value="MyUpdateTemplate.vm" />
<parameter name="action.browse" value="MyActionInStateBrowse" />
<parameter name="template.browse" value="MyDeleteTemplate.vm" />
etc...
2- Apply the following patch to VelocityPortlet:
Index: VelocityPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/Velo
cityPortlet.java,v
retrieving revision 1.20
diff -r1.20 VelocityPortlet.java
159c159,170
< String template = getPortletConfig().getInitParameter("template");
---
> String state = data.getParameters().getString("pstate");
>
> String templateName = "template";
> String actionName = "action";
>
> if ((state != null) && (!state.equals("")))
> {
> templateName = templateName + "." + state;
> actionName = actionName + "." + state;
> }
>
> String template =
getPortletConfig().getInitParameter(templateName);
181c192
< String actionName = getPortletConfig().getInitParameter("action");
---
> String actionName =
getPortletConfig().getInitParameter(actionName);
Et voila, your portlet now gives you basic built-in controller capabilities
so that you don't even have to use "setTemplate" unless you want to
redirect your user to a non-standard state template, plus you would have the
following flow control:
- page1.vm
- link1
- actionX.doEvent (depends on the "action" paramater included in the link)
- go to state 2
- action2.buildContext
- page2.vm
--
Rapha�l Luta - [EMAIL PROTECTED]
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>