You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by "Tomás P. Tapia" <to...@welinux.cl> on 2010/10/25 20:11:51 UTC

onProcess allways called and Overrides SetValue

Hi,

I'm new to click, i don't know if it's ok but :

ifi set the value to a control in the onInit() method, then onProcess() method overrides it without the form being submited. Until i understood the SetValue executed in onInit must be honored, moreover if there is no submission in course.

I'm using click 2.2.

Regards, 
Tomás Tapia Silva - Software Engineer



Re: onProcess allways called and Overrides SetValue

Posted by "Tomás P. Tapia" <to...@welinux.cl>.
Thanks Malcolm, this information is very helpful to me. 


Regards, 
Tomás Tapia Silva - Software Engineer 

----- Mensaje original -----
De: "Malcolm Edgar" <ma...@gmail.com> 
Para: "user" <us...@click.apache.org> 
Enviados: Lunes, 25 de Octubre 2010 19:47:21 
Asunto: Re: onProcess allways called and Overrides SetValue 

Hi Tomas, 


OK I don't think I read your original question correctly. I would recommend that you read the following blog 


http://click-framework.blogspot.com/2010/09/apache-click-220-explicit-binding.html 


http://click-framework.blogspot.com/2010/09/apache-click-220-dynamic-form.html 


regards Malcolm Edgar 


On Mon, Oct 25, 2010 at 2:54 PM, Tomás P. Tapia < tomas@welinux.cl > wrote: 


Malcolm, 

Thanks for your response and clarification. 

To be more precise: "we have problems setting default values for some dynamic fields". 

What is going on here is that we want to set default values on some fields, these fields has the characteristic of being created dynamically in the onInit method (i was cautious to use page.addControl in each of theses controls, in order to be recognized has such by ClickServlet). 

We set default values on these fields, but this default values were overwritten by the onProcess method besides this is not a form submission. is that the expected behavior ?, if onProcess allways overrides default values, where are these useful ? 


Regards, 
Tomás Tapia Silva - Software Engineer 


----- Mensaje original ----- 
De: "Malcolm Edgar" < malcolm.edgar@gmail.com > 
Para: "user" < user@click.apache.org > 
Enviados: Lunes, 25 de Octubre 2010 17:41:40 
Asunto: Re: onProcess allways called and Overrides SetValue 




Hi, 


Form fields binding is performed in the onProcess() method, not in the onInit() method. The onInit() method is used primarily for post construction operations, and is provided for your use. Click doesn't do anything special in this phase. 


Most of the action happens in the onProcess() phase. For example a Form control will determine whether it is being targeted in a request, and if so it will process all its child controls. All the form fields will then have their onProcess() method called. Fields generally implement a pattern in their onProcess() method where they perform data binding, validation and dispatch an event to any listeners. 


After the onProcess phase has been completed, the ClickServlet will fire event's to any registered listeners, for example an Submit control "onClick" listener. You can think of these as closures, and in fact were inspired by Delphi's function pointers. 



regards Malcolm Edgar 


On Mon, Oct 25, 2010 at 11:11 AM, Tomás P. Tapia < tomas@welinux.cl > wrote: 


Hi, 

I'm new to click, i don't know if it's ok but : 

ifi set the value to a control in the onInit() method, then onProcess() method overrides it without the form being submited. Until i understood the SetValue executed in onInit must be honored, moreover if there is no submission in course. 

I'm using click 2.2. 

Regards, 
Tomás Tapia Silva - Software Engineer 





Re: onProcess allways called and Overrides SetValue

Posted by Malcolm Edgar <ma...@gmail.com>.
Hi Tomas,

OK I don't think I read your original question correctly. I would recommend
that you read the following blog

http://click-framework.blogspot.com/2010/09/apache-click-220-explicit-binding.html

http://click-framework.blogspot.com/2010/09/apache-click-220-dynamic-form.html

regards Malcolm Edgar

On Mon, Oct 25, 2010 at 2:54 PM, Tomás P. Tapia <to...@welinux.cl> wrote:

> Malcolm,
>
> Thanks for your response and clarification.
>
> To be more precise: "we have problems setting default values for some
> dynamic fields".
>
> What is going on here is that we want to set default values on some fields,
> these fields has the characteristic of being created dynamically in the
> onInit method (i was cautious to use page.addControl in each of theses
> controls, in order to be recognized has such by ClickServlet).
>
> We set default values on these fields, but this default values were
> overwritten by the onProcess method besides this is not a form submission.
>  is that the expected behavior ?, if onProcess allways overrides default
> values, where are these useful ?
>
> Regards,
> Tomás Tapia Silva - Software Engineer
>
>
> ----- Mensaje original -----
> De: "Malcolm Edgar" <ma...@gmail.com>
> Para: "user" <us...@click.apache.org>
> Enviados: Lunes, 25 de Octubre 2010 17:41:40
> Asunto: Re: onProcess allways called and Overrides SetValue
>
> Hi,
>
>
> Form fields binding is performed in the onProcess() method, not in the
> onInit() method. The onInit() method is used primarily for post construction
> operations, and is provided for your use. Click doesn't do anything special
> in this phase.
>
>
> Most of the action happens in the onProcess() phase. For example a Form
> control will determine whether it is being targeted in a request, and if so
> it will process all its child controls. All the form fields will then have
> their onProcess() method called. Fields generally implement a pattern in
> their onProcess() method where they perform data binding, validation and
> dispatch an event to any listeners.
>
>
> After the onProcess phase has been completed, the ClickServlet will fire
> event's to any registered listeners, for example an Submit control "onClick"
> listener. You can think of these as closures, and in fact were inspired by
> Delphi's function pointers.
>
>
>
> regards Malcolm Edgar
>
>
> On Mon, Oct 25, 2010 at 11:11 AM, Tomás P. Tapia < tomas@welinux.cl >
> wrote:
>
>
> Hi,
>
> I'm new to click, i don't know if it's ok but :
>
> ifi set the value to a control in the onInit() method, then onProcess()
> method overrides it without the form being submited. Until i understood the
> SetValue executed in onInit must be honored, moreover if there is no
> submission in course.
>
> I'm using click 2.2.
>
> Regards,
> Tomás Tapia Silva - Software Engineer
>
>
>
>

Re: onProcess allways called and Overrides SetValue

Posted by Bob Schellink <sa...@gmail.com>.
Hi Tomas,

On 26/10/2010 08:54, Tomás P. Tapia wrote:
> To be more precise: "we have problems setting default values for some dynamic fields".
>
> What is going on here is that we want to set default values on some fields, these fields has the characteristic of being created dynamically in the onInit method (i was cautious to use page.addControl in each of theses controls, in order to be recognized has such by ClickServlet).
Any reason you are you adding fields to the Page, and not the form? By adding Fields to the Page,
you are telling Click to process them every request, whether it is a GET or a POST. Forms on the
other hand only process their children on submissions so should give the behavior you are after.
Further, fields outside Forms aren't very useful as their values won't be posted to the server.

> We set default values on these fields, but this default values were overwritten by the onProcess method besides this is not a form submission.  is that the expected behavior ?, if onProcess allways overrides default values, where are these useful ?
I have been thinking that Field onProcess behavior should check if there is a matching request
parameter before setting it's value (which is the behavior you are seeing as well). If there is no
incoming value, the Field shouldn't be processed or validated.

Kind regards

Bob

Re: onProcess allways called and Overrides SetValue

Posted by "Tomás P. Tapia" <to...@welinux.cl>.
Malcolm,

Thanks for your response and clarification.

To be more precise: "we have problems setting default values for some dynamic fields".

What is going on here is that we want to set default values on some fields, these fields has the characteristic of being created dynamically in the onInit method (i was cautious to use page.addControl in each of theses controls, in order to be recognized has such by ClickServlet).

We set default values on these fields, but this default values were overwritten by the onProcess method besides this is not a form submission.  is that the expected behavior ?, if onProcess allways overrides default values, where are these useful ?

Regards, 
Tomás Tapia Silva - Software Engineer


----- Mensaje original -----
De: "Malcolm Edgar" <ma...@gmail.com>
Para: "user" <us...@click.apache.org>
Enviados: Lunes, 25 de Octubre 2010 17:41:40
Asunto: Re: onProcess allways called and Overrides SetValue

Hi, 


Form fields binding is performed in the onProcess() method, not in the onInit() method. The onInit() method is used primarily for post construction operations, and is provided for your use. Click doesn't do anything special in this phase. 


Most of the action happens in the onProcess() phase. For example a Form control will determine whether it is being targeted in a request, and if so it will process all its child controls. All the form fields will then have their onProcess() method called. Fields generally implement a pattern in their onProcess() method where they perform data binding, validation and dispatch an event to any listeners. 


After the onProcess phase has been completed, the ClickServlet will fire event's to any registered listeners, for example an Submit control "onClick" listener. You can think of these as closures, and in fact were inspired by Delphi's function pointers. 



regards Malcolm Edgar 


On Mon, Oct 25, 2010 at 11:11 AM, Tomás P. Tapia < tomas@welinux.cl > wrote: 


Hi, 

I'm new to click, i don't know if it's ok but : 

ifi set the value to a control in the onInit() method, then onProcess() method overrides it without the form being submited. Until i understood the SetValue executed in onInit must be honored, moreover if there is no submission in course. 

I'm using click 2.2. 

Regards, 
Tomás Tapia Silva - Software Engineer 




Re: onProcess allways called and Overrides SetValue

Posted by Malcolm Edgar <ma...@gmail.com>.
Hi,

Form fields binding is performed in the onProcess() method, not in the
onInit() method.  The onInit() method is used primarily for post
construction operations, and is provided for your use. Click doesn't do
anything special in this phase.

Most of the action happens in the onProcess() phase. For example a Form
control will determine whether it is being targeted in a request, and if so
it will process all its child controls.  All the form fields will then have
their onProcess() method called.  Fields generally implement a pattern in
their onProcess() method where they perform data binding, validation and
dispatch an event to any listeners.

After the onProcess phase has been completed, the ClickServlet will fire
event's to any registered listeners, for example an Submit control "onClick"
listener. You can think of these as closures, and in fact were inspired by
Delphi's function pointers.

regards Malcolm Edgar

On Mon, Oct 25, 2010 at 11:11 AM, Tomás P. Tapia <to...@welinux.cl> wrote:

> Hi,
>
> I'm new to click, i don't know if it's ok but :
>
> ifi set the value to a control in the onInit() method, then onProcess()
> method overrides it without the form being submited. Until i understood the
> SetValue executed in onInit must be honored, moreover if there is no
> submission in course.
>
> I'm using click 2.2.
>
> Regards,
> Tomás Tapia Silva - Software Engineer
>
>
>