You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Bob Schellink <sa...@gmail.com> on 2010/01/18 09:34:12 UTC
On demand binding
Hi all,
Thought I'd solicit some feedback on a new feature I've been pondering about the last couple of days.
Enter On Demand Binding, the ability for a field to bind to its request parameter when needed!
Controls are bound to incoming request parameters during the onProcess phase. However often times we
need to know a control's value during the onInit phase, so we can perform conditional logic such as
adding new fields to a form.
Currently we can either bind a field value explicitly using the method #bindRequestValue, or inspect
the HttpRequest parameters:
public void onInit() {
Checkbox chk = new Checkbox("chk");
chk.bindRequestValue(); // Without On Demand Binding, we need to bind explicitly
if (chk.isChecked()) {
form.add(new TextField("comment"));
}
}
The idea with On Demand Binding is that Fields should bind to its incoming request parameter when
needed. For example:
public void onInit() {
Checkbox chk = new Checkbox("chk");
if (chk.isChecked()) {
form.add(new TextField("comment"));
}
}
What do you think? Will this feature be useful or cause unnecessary confusion?
kind regards
bob
Re: On demand binding
Posted by Malcolm Edgar <ma...@gmail.com>.
In think we are getting out of the normal page execution scenario so
its doesn't really make sense. Also a submit button will always
probably be valid, however the parent form may not be.
regards Malcolm Edgar
On Wed, Jan 20, 2010 at 11:01 PM, Bob Schellink <sa...@gmail.com> wrote:
> I wonder how an on demand binding feature would influence validation. Should
> validation also be done lazily? Otherwise one might end up with:
>
> public void onInit() {
>
> Submit submit = new Submit("submit");
> if (submit.isClicked()) {
> if (submit.isValid()) {
> // At this stage the isValid call will return true since no validation
> was done yet
> }
> }
> }
>
> regards
>
> bob
>
> On 18/01/2010 11:23 PM, Malcolm Edgar wrote:
>>
>> +1 I think this is a good idea, so long as the fields parent form
>> submit status is respected, i.e. if a page has two forms only fields
>> belonging to the submitted form should be able to bind their fields.
>>
>> regards Malcolm Edgar
>>
>> On Mon, Jan 18, 2010 at 7:34 PM, Bob Schellink<sa...@gmail.com> wrote:
>>>
>>> Hi all,
>>>
>>> Thought I'd solicit some feedback on a new feature I've been pondering
>>> about
>>> the last couple of days.
>>>
>>> Enter On Demand Binding, the ability for a field to bind to its request
>>> parameter when needed!
>>>
>>> Controls are bound to incoming request parameters during the onProcess
>>> phase. However often times we need to know a control's value during the
>>> onInit phase, so we can perform conditional logic such as adding new
>>> fields
>>> to a form.
>>>
>>> Currently we can either bind a field value explicitly using the method
>>> #bindRequestValue, or inspect the HttpRequest parameters:
>>>
>>> public void onInit() {
>>>
>>> Checkbox chk = new Checkbox("chk");
>>> chk.bindRequestValue(); // Without On Demand Binding, we need to bind
>>> explicitly
>>>
>>> if (chk.isChecked()) {
>>> form.add(new TextField("comment"));
>>> }
>>> }
>>>
>>> The idea with On Demand Binding is that Fields should bind to its
>>> incoming
>>> request parameter when needed. For example:
>>>
>>> public void onInit() {
>>>
>>> Checkbox chk = new Checkbox("chk");
>>>
>>> if (chk.isChecked()) {
>>> form.add(new TextField("comment"));
>>> }
>>> }
>>>
>>>
>>> What do you think? Will this feature be useful or cause unnecessary
>>> confusion?
>>>
>>> kind regards
>>>
>>> bob
>>>
>>
>
>
Re: On demand binding
Posted by Bob Schellink <sa...@gmail.com>.
I wonder how an on demand binding feature would influence validation. Should validation also be done
lazily? Otherwise one might end up with:
public void onInit() {
Submit submit = new Submit("submit");
if (submit.isClicked()) {
if (submit.isValid()) {
// At this stage the isValid call will return true since no validation was done yet
}
}
}
regards
bob
On 18/01/2010 11:23 PM, Malcolm Edgar wrote:
> +1 I think this is a good idea, so long as the fields parent form
> submit status is respected, i.e. if a page has two forms only fields
> belonging to the submitted form should be able to bind their fields.
>
> regards Malcolm Edgar
>
> On Mon, Jan 18, 2010 at 7:34 PM, Bob Schellink<sa...@gmail.com> wrote:
>> Hi all,
>>
>> Thought I'd solicit some feedback on a new feature I've been pondering about
>> the last couple of days.
>>
>> Enter On Demand Binding, the ability for a field to bind to its request
>> parameter when needed!
>>
>> Controls are bound to incoming request parameters during the onProcess
>> phase. However often times we need to know a control's value during the
>> onInit phase, so we can perform conditional logic such as adding new fields
>> to a form.
>>
>> Currently we can either bind a field value explicitly using the method
>> #bindRequestValue, or inspect the HttpRequest parameters:
>>
>> public void onInit() {
>>
>> Checkbox chk = new Checkbox("chk");
>> chk.bindRequestValue(); // Without On Demand Binding, we need to bind
>> explicitly
>>
>> if (chk.isChecked()) {
>> form.add(new TextField("comment"));
>> }
>> }
>>
>> The idea with On Demand Binding is that Fields should bind to its incoming
>> request parameter when needed. For example:
>>
>> public void onInit() {
>>
>> Checkbox chk = new Checkbox("chk");
>>
>> if (chk.isChecked()) {
>> form.add(new TextField("comment"));
>> }
>> }
>>
>>
>> What do you think? Will this feature be useful or cause unnecessary
>> confusion?
>>
>> kind regards
>>
>> bob
>>
>
Re: On demand binding
Posted by Malcolm Edgar <ma...@gmail.com>.
+1 I think this is a good idea, so long as the fields parent form
submit status is respected, i.e. if a page has two forms only fields
belonging to the submitted form should be able to bind their fields.
regards Malcolm Edgar
On Mon, Jan 18, 2010 at 7:34 PM, Bob Schellink <sa...@gmail.com> wrote:
> Hi all,
>
> Thought I'd solicit some feedback on a new feature I've been pondering about
> the last couple of days.
>
> Enter On Demand Binding, the ability for a field to bind to its request
> parameter when needed!
>
> Controls are bound to incoming request parameters during the onProcess
> phase. However often times we need to know a control's value during the
> onInit phase, so we can perform conditional logic such as adding new fields
> to a form.
>
> Currently we can either bind a field value explicitly using the method
> #bindRequestValue, or inspect the HttpRequest parameters:
>
> public void onInit() {
>
> Checkbox chk = new Checkbox("chk");
> chk.bindRequestValue(); // Without On Demand Binding, we need to bind
> explicitly
>
> if (chk.isChecked()) {
> form.add(new TextField("comment"));
> }
> }
>
> The idea with On Demand Binding is that Fields should bind to its incoming
> request parameter when needed. For example:
>
> public void onInit() {
>
> Checkbox chk = new Checkbox("chk");
>
> if (chk.isChecked()) {
> form.add(new TextField("comment"));
> }
> }
>
>
> What do you think? Will this feature be useful or cause unnecessary
> confusion?
>
> kind regards
>
> bob
>
Re: On demand binding
Posted by Malcolm Edgar <ma...@gmail.com>.
+1 I think this is a good idea, so long as the fields parent form
submit status is respected, i.e. if a page has two forms only fields
belonging to the submitted form should be able to bind their fields.
regards Malcolm Edgar
On Mon, Jan 18, 2010 at 7:34 PM, Bob Schellink <sa...@gmail.com> wrote:
> Hi all,
>
> Thought I'd solicit some feedback on a new feature I've been pondering about
> the last couple of days.
>
> Enter On Demand Binding, the ability for a field to bind to its request
> parameter when needed!
>
> Controls are bound to incoming request parameters during the onProcess
> phase. However often times we need to know a control's value during the
> onInit phase, so we can perform conditional logic such as adding new fields
> to a form.
>
> Currently we can either bind a field value explicitly using the method
> #bindRequestValue, or inspect the HttpRequest parameters:
>
> public void onInit() {
>
> Checkbox chk = new Checkbox("chk");
> chk.bindRequestValue(); // Without On Demand Binding, we need to bind
> explicitly
>
> if (chk.isChecked()) {
> form.add(new TextField("comment"));
> }
> }
>
> The idea with On Demand Binding is that Fields should bind to its incoming
> request parameter when needed. For example:
>
> public void onInit() {
>
> Checkbox chk = new Checkbox("chk");
>
> if (chk.isChecked()) {
> form.add(new TextField("comment"));
> }
> }
>
>
> What do you think? Will this feature be useful or cause unnecessary
> confusion?
>
> kind regards
>
> bob
>