-
1. Re: sharing data between render() and processAction() method
hubertg Jul 17, 2006 9:19 AM (in response to hubertg)correction:
of course i meantrequest.getPortletSession().setAttribute("sharedData", value);
andObject data = request.getPortletSession().getAttribute("sharedData");
an edit function would be great ... :-) -
2. Re: sharing data between render() and processAction() method
bdaw Jul 18, 2006 12:42 PM (in response to hubertg)for string values just use:
PortletURL url = response.createActionURL(); url.setParameter(?paymentMethod?,?creditCardInProfile?);
I'm not sure in which order you want to pass those objects.
If render --> action
Your concerns are correct. Render phase for a portlet can be triggered multiply times with unpredictable order beetween portlets on the same page and you have no influence on this.
If action --> render
You simply use ActionRequest.setAttribute(), RenderRequest.getAttribute() or ActionRequest.setRenderParameter() which is better practice than using a session -
3. Re: sharing data between render() and processAction() method
hubertg Jul 18, 2006 1:29 PM (in response to hubertg)thanks for your answer.
The order is:
1. processAction() portlet A
2. render() portlet A
3. render() portlet B
4. render() other portlests C,D, ...
I'm porting a MVC web framework (WebWork 1) into a portlet. The classical MVC approach is based on one atomic request-response cycle. The action class needs the input parameters, creates a ValueStack (the action's result) which is passed to the jsp pages via request attributes. In the portlet I have to split this process into two phases, namely the processAction and the render phase. Therefore I need a way to pass the ValueStack from the processAction phase to the render phase.
I think render params are no solution for my problem because first I don't want to make results directly visible for the user and second it's practically impossible to set java objects as render objects.
br, hubert -
4. Re: sharing data between render() and processAction() method
bdaw Jul 18, 2006 2:00 PM (in response to hubertg)you do ActionRequest.setAttribute(Object o) and RenderRequest.getAttribute(...)
Consider using MVC web framework that has bridge/support for portlets. JSF and struts has some.
And read portlet specification (jsr-168) - it's not very long and really readable ;) -
5. Re: sharing data between render() and processAction() method
hubertg Jul 18, 2006 3:04 PM (in response to hubertg)I may be wrong, but I think by using your suggested commands the Object o won't be accessible in the RenderRequest. If it were I'd happily use this method of sharing objects between the methods.
The only way is to use ActionResponse::setRenderParameter(String). Then the renderparameter is simply added to the url used for redirect (/portal/default/?renderparam1=value).
Render and ActionREquest are two different HTTPServletRequest and not sharing any objects. Thats at least what I remember from JSR 168 :-)
JSF and struts are no real alternatives because the current system is based on webwork 1. I used the StrutsBridge as some kind of inspiration though. -
6. Re: sharing data between render() and processAction() method
bdaw Jul 18, 2006 3:32 PM (in response to hubertg)arf... ok. of course your right. I wrote the anwser to fast and it is wrong. sory for that.... very stupid from my side.