Thank Gilberto for your instant response.
 
--- El mar 19-abr-11, Gilberto <[email protected]> escribió:


De: Gilberto <[email protected]>
Asunto: Re: instance variable, no preserve value, inter call distinct methods
Para: [email protected]
Fecha: martes, 19 de abril de 2011, 11:21


On Tue, Apr 19, 2011 at 10:36 AM, Antonio Bodoc <[email protected]> wrote:
>
> Hi
>
> In an instance variable I put path to return by default in the constructor 
> method.
>
> @Component
> public class OrdenEdit extends com.bas.eservice.page.BorderPage {
>     ...
>     private String toReturn;
>     ...
>     public OrdenEdit() {
>         toReturn = "/admin/orden-table.htm";
>         ...
>     }
>
>
> In the method onGet()  I modify that value from a value stored in the Session 
> Object.
>     ...
>     @Override
>     public void onGet() {
>        ...
>        toReturn = getContext().getSessionAttribute("orden.return");
>        // "/admin/orden-edit.htm" -> toReturn
>        ...
>     }
>
> Soon use the variable in a method onCancelClick, but the value that it has, 
> is original and not placed in the method onGet.
>     public boolean onCancelClick() {
>         ...
>         setRedirect(toReturn);
>         // toReturn value is "/admin/orden-table.htm" instead of 
> "/admin/orden-edit.htm"
>     }
>
> It is not preserved in value of an instance variable between calls to 
> different methods from the same page ???

Hi, Jorge.

You're correct! Every time you do a request, be it a get or post, we
get all page execution[1].
I'm used to put two instance variable in my page controller, for
example, when using the view->edit pattern: one for the onGet() and
other for the onPost() method. The onPost one been hidden field.

Regards,

Gilberto
[1]http://click.apache.org/docs/click-api/org/apache/click/Page.html
>
>
> Thank
> Sorry for my bad english
>
> Jorge

Reply via email to