portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Winburn" <jwinb...@computerguidance.com>
Subject RE: Double Action problem
Date Tue, 16 Dec 2008 14:14:21 GMT
Thank you Woonsan,

Although your suggestion to keep all getParameter() calls inside
processAction() runs counter to all my documentation on how to build
portlets, it is elegant, more structured, and fosters cohesion. AND it
even works.

James Winburn


-----Original Message-----
From: Woonsan Ko [mailto:woon_san@yahoo.com] 
Sent: Tuesday, December 16, 2008 1:11 AM
To: Jetspeed Developers List
Subject: Re: Double Action problem

Hi James,

I'm not sure if I understand your case, but I can say that doEdit()
could be called multiple times and getting parameters from the user form
should be done in the processAction() method ("action phase") only.
The doEdit() method is just in "rendering phase" like doView().
If you want to store something for rendering phase, you can set a
parameter by actionResponse.setRenderParameter() in your processAction()
method, or you can set a portlet session attribute.
In the former case, the portal page can be redirected to another url.
This is a case you can see doEdit() invoked twice, but it is not a
problem but a normal behavior.
Anyway, I think you should stick to processAction() to retrieve
something from the user form.

Regards,

Woonsan


--- On Mon, 12/15/08, James Winburn <jwinburn@computerguidance.com>
wrote:

> From: James Winburn <jwinburn@computerguidance.com>
> Subject: Double Action problem
> To: "Jetspeed Developers List" <jetspeed-dev@portals.apache.org>
> Date: Monday, December 15, 2008, 10:40 PM
> Hey Guys,
> 
>  
> 
> When linking back to the portal server in edit mode, I am
> finding that
> doEdit() is called twice.
> 
>  
> 
> Here is my code for doEdit():
> 
>   
> 
> public void doEdit(RenderRequest request,RenderResponse
> response) 
> 
>    throws PortletException,IOException {
> 
>         
> 
>         response.setContentType("text/html");
> 
>         PrintWriter out=response.getWriter();
> 
>        
> 
>         out.print("<form action=" +
> response.createActionURL() + " >");
> 
>  
> 
>         String src =
> (String)request.getParameter("srcText");
> 
>         if (src==null){
> 
>             src = DEFAULT_SRC;
> 
>         } 
> 
>         out.print("<input
> type=\"text\"
> name=\"srcText\" value=\"" +
> src
> + "\" >");
> 
>         out.print("<br><br>");
> 
>         out.print("<input
> type=\"submit\"
> name=\"SUBMIT\"
> value=\"save\">");         
> 
>         out.print("</form>");            
> 
>     }
> 
>     
> 
> When going into edit mode, doEdit() is run.  The form
> hasn't been
> written to the screen yet and getParameter() therefore
> returns
> nothing...as it should.  The form is displayed in the
> portlet with the
> default source.
> 
>  
> 
> On a click to the submit button, doEdit() is run again, but
> this time
> getParameter() returns whatever it found in the text box. 
> All well and
> good.
> 
>  
> 
> But a second call to doEdit() is somehow triggered.  This
> time
> getParameter() returns nothing and it is subsequently
> filled with the
> default value....again.
> 
>  
> 
> My question is, why is doEdit being called that second
> time?  My guess
> is that the first time is a response to the actionURL and
> the second
> time is the system "setting to edit mode" again.
> 
>  
> 
> Since the second invocation essentially overwrites the
> fetched "src"
> value with the default, it's like I never entered
> anything in the field.
> I was unable to find out why that second doEdit() should be
> happening
> from googly-research.  I was hoping one of you might steer
> me in.
> 
>     
> 
> James Winburn  
> 
> Computer Guidance Corporation
> 
> Scottsdale, AZ


      

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message