You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by WicketKeeper <ma...@lehman.com> on 2007/11/01 11:25:15 UTC

Synchronizing AutoCompleteTextField with a checkbox

Hi

I have an autocomplete field object with the getChoices method overridden,
which works just fine. Next to it I have a checkbox, which when checked
alters the logic in getChoices so that the string is interpreted as a
regular expression.

This DOES work:

tsf = new TableSelectionField("TableNameAutoCompleteTextField");
subjcb = new CheckBox("SubjectsRegexpCheckBox")
        {
        	protected boolean wantOnSelectionChangedNotifications()
        	{
        		return true;
        	}
        };

both components are added to form, so they implicitly get the
CompoundPropertyModel.

Right, that's wonderful - except now when I click the checkbox the entire
page refreshes. When there's lots of stuff on the page this can be a heavy
operation. So I took this bit out:

subjcb = new CheckBox("SubjectsRegexpCheckBox")
        {
        	protected boolean wantOnSelectionChangedNotifications()
        	{
        		return true;
        	}
        };

And now the autocomplete field does not work - well, not completely. If I
click submit on the form (which gets that state of the checkbox and field) I
get the expected results, even if the autocomplete field doesn't populate
correctly.

Is there any way I can get round this without forcing a refresh when i click
on the checkbox?

Cheers
WK
-- 
View this message in context: http://www.nabble.com/Synchronizing-AutoCompleteTextField-with-a-checkbox-tf4730399.html#a13526176
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Synchronizing AutoCompleteTextField with a checkbox

Posted by Dipu Seminlal <di...@googlemail.com>.
hmmm, thats even better :)

On 11/1/07, WicketKeeper <ma...@lehman.com> wrote:
>
>
> I'm a dumdum.
> The answer is to use AjaxCheckBox (duhh)
> Cheers
> WK
>
>
> WicketKeeper wrote:
> >
> > Hi
> >
> > I have an autocomplete field object with the getChoices method
> overridden,
> > which works just fine. Next to it I have a checkbox, which when checked
> > alters the logic in getChoices so that the string is interpreted as a
> > regular expression.
> >
> > This DOES work:
> >
> > tsf = new TableSelectionField("TableNameAutoCompleteTextField");
> > subjcb = new CheckBox("SubjectsRegexpCheckBox")
> >         {
> >               protected boolean wantOnSelectionChangedNotifications()
> >               {
> >                       return true;
> >               }
> >         };
> >
> > both components are added to form, so they implicitly get the
> > CompoundPropertyModel.
> >
> > Right, that's wonderful - except now when I click the checkbox the
> entire
> > page refreshes. When there's lots of stuff on the page this can be a
> heavy
> > operation. So I took this bit out:
> >
> > subjcb = new CheckBox("SubjectsRegexpCheckBox")
> >         {
> >               protected boolean wantOnSelectionChangedNotifications()
> >               {
> >                       return true;
> >               }
> >         };
> >
> > And now the autocomplete field does not work - well, not completely. If
> I
> > click submit on the form (which gets that state of the checkbox and
> field)
> > I get the expected results, even if the autocomplete field doesn't
> > populate correctly.
> >
> > Is there any way I can get round this without forcing a refresh when i
> > click on the checkbox?
> >
> > Cheers
> > WK
> >
>
> --
> View this message in context:
> http://www.nabble.com/Synchronizing-AutoCompleteTextField-with-a-checkbox-tf4730399.html#a13526222
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Synchronizing AutoCompleteTextField with a checkbox

Posted by WicketKeeper <ma...@lehman.com>.
I'm a dumdum.
The answer is to use AjaxCheckBox (duhh)
Cheers
WK


WicketKeeper wrote:
> 
> Hi
> 
> I have an autocomplete field object with the getChoices method overridden,
> which works just fine. Next to it I have a checkbox, which when checked
> alters the logic in getChoices so that the string is interpreted as a
> regular expression.
> 
> This DOES work:
> 
> tsf = new TableSelectionField("TableNameAutoCompleteTextField");
> subjcb = new CheckBox("SubjectsRegexpCheckBox")
>         {
>         	protected boolean wantOnSelectionChangedNotifications()
>         	{
>         		return true;
>         	}
>         };
> 
> both components are added to form, so they implicitly get the
> CompoundPropertyModel.
> 
> Right, that's wonderful - except now when I click the checkbox the entire
> page refreshes. When there's lots of stuff on the page this can be a heavy
> operation. So I took this bit out:
> 
> subjcb = new CheckBox("SubjectsRegexpCheckBox")
>         {
>         	protected boolean wantOnSelectionChangedNotifications()
>         	{
>         		return true;
>         	}
>         };
> 
> And now the autocomplete field does not work - well, not completely. If I
> click submit on the form (which gets that state of the checkbox and field)
> I get the expected results, even if the autocomplete field doesn't
> populate correctly.
> 
> Is there any way I can get round this without forcing a refresh when i
> click on the checkbox?
> 
> Cheers
> WK
> 

-- 
View this message in context: http://www.nabble.com/Synchronizing-AutoCompleteTextField-with-a-checkbox-tf4730399.html#a13526222
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Synchronizing AutoCompleteTextField with a checkbox

Posted by WicketKeeper <ma...@lehman.com>.
That would work as well, yes. I don't know if this is good practice, but the
way I've done it now, which works, is:

tsf = new TableSelectionField("TableNameAutoCompleteTextField"); 
AjaxCheckBox tncb = new AjaxCheckBox("TableNamesRegexpCheckBox")
        {
        	public void onUpdate(AjaxRequestTarget target)
        	{
        		//squelch! does nothing
        	}
        };
tsf.setRegexp(tncb); //don't know if this is good practice, but works 

In the model I have methods:
	public void setTableNamesRegexpCheckBox(boolean b)
	{
		this.b_tablenames = b;
	}
	
	public boolean getTableNamesRegexpCheckBox()
	{
		return b_tablenames;
	}
	public String getTableNameAutoCompleteTextField()
	{
		return s_tablenames;
	}
	
	public void setTableNameAutoCompleteTextField(String s)
	{
		s_tablenames = s;
	}

And in the getChoices method for the textfield I have the following logic:

if((Boolean)regexp.getModelObject())
{
    //regular expression
}
else
{
  //normal
}

Cheers
WK


Dipu Seminlal wrote:
> 
> try adding AjaxFormComponentUpdatingBehaviour to the the check box instead
> of
> setting wantOnSelectionChangedNotifications.
> 
> as far as i know wantOnSelectionChangedNotifications will refresh the
> page.
> 
> AjaxFormComponentUpdatingBehaviour will do an ajax call and won't refresh
> the entire page.
> 
> Regards
> Dipu
> 
> 
> On 11/1/07, WicketKeeper <ma...@lehman.com> wrote:
>>
>>
>> Hi
>>
>> I have an autocomplete field object with the getChoices method
>> overridden,
>> which works just fine. Next to it I have a checkbox, which when checked
>> alters the logic in getChoices so that the string is interpreted as a
>> regular expression.
>>
>> This DOES work:
>>
>> tsf = new TableSelectionField("TableNameAutoCompleteTextField");
>> subjcb = new CheckBox("SubjectsRegexpCheckBox")
>>         {
>>                 protected boolean wantOnSelectionChangedNotifications()
>>                 {
>>                         return true;
>>                 }
>>         };
>>
>> both components are added to form, so they implicitly get the
>> CompoundPropertyModel.
>>
>> Right, that's wonderful - except now when I click the checkbox the entire
>> page refreshes. When there's lots of stuff on the page this can be a
>> heavy
>> operation. So I took this bit out:
>>
>> subjcb = new CheckBox("SubjectsRegexpCheckBox")
>>         {
>>                 protected boolean wantOnSelectionChangedNotifications()
>>                 {
>>                         return true;
>>                 }
>>         };
>>
>> And now the autocomplete field does not work - well, not completely. If I
>> click submit on the form (which gets that state of the checkbox and
>> field)
>> I
>> get the expected results, even if the autocomplete field doesn't populate
>> correctly.
>>
>> Is there any way I can get round this without forcing a refresh when i
>> click
>> on the checkbox?
>>
>> Cheers
>> WK
>> --
>> View this message in context:
>> http://www.nabble.com/Synchronizing-AutoCompleteTextField-with-a-checkbox-tf4730399.html#a13526176
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Synchronizing-AutoCompleteTextField-with-a-checkbox-tf4730399.html#a13526416
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Synchronizing AutoCompleteTextField with a checkbox

Posted by Dipu Seminlal <di...@googlemail.com>.
try adding AjaxFormComponentUpdatingBehaviour to the the check box instead
of
setting wantOnSelectionChangedNotifications.

as far as i know wantOnSelectionChangedNotifications will refresh the page.

AjaxFormComponentUpdatingBehaviour will do an ajax call and won't refresh
the entire page.

Regards
Dipu


On 11/1/07, WicketKeeper <ma...@lehman.com> wrote:
>
>
> Hi
>
> I have an autocomplete field object with the getChoices method overridden,
> which works just fine. Next to it I have a checkbox, which when checked
> alters the logic in getChoices so that the string is interpreted as a
> regular expression.
>
> This DOES work:
>
> tsf = new TableSelectionField("TableNameAutoCompleteTextField");
> subjcb = new CheckBox("SubjectsRegexpCheckBox")
>         {
>                 protected boolean wantOnSelectionChangedNotifications()
>                 {
>                         return true;
>                 }
>         };
>
> both components are added to form, so they implicitly get the
> CompoundPropertyModel.
>
> Right, that's wonderful - except now when I click the checkbox the entire
> page refreshes. When there's lots of stuff on the page this can be a heavy
> operation. So I took this bit out:
>
> subjcb = new CheckBox("SubjectsRegexpCheckBox")
>         {
>                 protected boolean wantOnSelectionChangedNotifications()
>                 {
>                         return true;
>                 }
>         };
>
> And now the autocomplete field does not work - well, not completely. If I
> click submit on the form (which gets that state of the checkbox and field)
> I
> get the expected results, even if the autocomplete field doesn't populate
> correctly.
>
> Is there any way I can get round this without forcing a refresh when i
> click
> on the checkbox?
>
> Cheers
> WK
> --
> View this message in context:
> http://www.nabble.com/Synchronizing-AutoCompleteTextField-with-a-checkbox-tf4730399.html#a13526176
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>