You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by sp...@indiana.edu on 2005/11/04 05:28:48 UTC
Checkbox event
Hi,
I need to display a list box when a checkbox is clicked. I guess we need to
implement OnSelect event for this purpose. Please, correct me here if I am wrong.
Does anybody have some examples of using onSelect in the backing bean?. Any help
is appreciated.
-Suba.
Re: Checkbox event
Posted by Bruno Aranda <br...@gmail.com>.
Maybe a variation of the method proposed in
http://wiki.apache.org/myfaces/SubmitPageOnValueChange is useful to
you. You can have a hidden (with css) button that is clicked
automatically when you select the checkbox...
Regards,
Bruno
2005/11/4, speriyas@indiana.edu <sp...@indiana.edu>:
> That was helpful. But, I would like to try some other way to utilize the power
> of JSF :).
>
> Is there a action event or valuechange event for checkbox. Any idea?
>
> Thanks.
>
>
> Quoting Simon Kitching <sk...@obsidium.com>:
>
> > speriyas@indiana.edu wrote:
> > > Hi,
> > >
> > > I need to display a list box when a checkbox is clicked. I guess we need
> > to
> > > implement OnSelect event for this purpose. Please, correct me here if I am
> > wrong.
> > > Does anybody have some examples of using onSelect in the backing bean?.
> > Any help
> > > is appreciated.
> > >
> >
> > onSelect is a *client side* thing only. It is a normal HTML feature that
> > allows an arbitrary piece of scripting to be run in the browser. Nothing
> > to do with JSF at all.
> >
> > You could implement what you want entirely on the client by ensuring
> > your page includes the listbox, but with its style set to display:none.
> > You should then be able to specify some script in the checkbox onSelect
> > attribute which finds that component and sets its style to visible. This
> > is really not JSF at all but that doesn't mean it's a bad solution.
> >
> > Alternatively, I expect you could map the checkbox value to some boolean
> > value on a backing bean, and use the same value to control the
> > "rendered" attribute of the listbox.
> > <h:selectBooleanCheckbox value="#{someBean.listBoxEnabled}"/>
> > <h:selectManyListbox rendered="#{someBean.listBoxEnabled}" ... />
> > The problem here is that you need some mechanism for submitting the
> > entire form back to the server when the checkbox value is changed so the
> > page can be regenerated.
> >
> >
> > Maybe you can use tomahawk's collapsible panel control instead of the
> > checkbox/listbox combination, and avoid the whole issue?
> >
> > Regards,
> >
> > Simon
> >
>
>
>
Re: Checkbox event
Posted by sp...@indiana.edu.
That was helpful. But, I would like to try some other way to utilize the power
of JSF :).
Is there a action event or valuechange event for checkbox. Any idea?
Thanks.
Quoting Simon Kitching <sk...@obsidium.com>:
> speriyas@indiana.edu wrote:
> > Hi,
> >
> > I need to display a list box when a checkbox is clicked. I guess we need
> to
> > implement OnSelect event for this purpose. Please, correct me here if I am
> wrong.
> > Does anybody have some examples of using onSelect in the backing bean?.
> Any help
> > is appreciated.
> >
>
> onSelect is a *client side* thing only. It is a normal HTML feature that
> allows an arbitrary piece of scripting to be run in the browser. Nothing
> to do with JSF at all.
>
> You could implement what you want entirely on the client by ensuring
> your page includes the listbox, but with its style set to display:none.
> You should then be able to specify some script in the checkbox onSelect
> attribute which finds that component and sets its style to visible. This
> is really not JSF at all but that doesn't mean it's a bad solution.
>
> Alternatively, I expect you could map the checkbox value to some boolean
> value on a backing bean, and use the same value to control the
> "rendered" attribute of the listbox.
> <h:selectBooleanCheckbox value="#{someBean.listBoxEnabled}"/>
> <h:selectManyListbox rendered="#{someBean.listBoxEnabled}" ... />
> The problem here is that you need some mechanism for submitting the
> entire form back to the server when the checkbox value is changed so the
> page can be regenerated.
>
>
> Maybe you can use tomahawk's collapsible panel control instead of the
> checkbox/listbox combination, and avoid the whole issue?
>
> Regards,
>
> Simon
>
Re: Checkbox event
Posted by Simon Kitching <sk...@obsidium.com>.
speriyas@indiana.edu wrote:
> Hi,
>
> I need to display a list box when a checkbox is clicked. I guess we need to
> implement OnSelect event for this purpose. Please, correct me here if I am wrong.
> Does anybody have some examples of using onSelect in the backing bean?. Any help
> is appreciated.
>
onSelect is a *client side* thing only. It is a normal HTML feature that
allows an arbitrary piece of scripting to be run in the browser. Nothing
to do with JSF at all.
You could implement what you want entirely on the client by ensuring
your page includes the listbox, but with its style set to display:none.
You should then be able to specify some script in the checkbox onSelect
attribute which finds that component and sets its style to visible. This
is really not JSF at all but that doesn't mean it's a bad solution.
Alternatively, I expect you could map the checkbox value to some boolean
value on a backing bean, and use the same value to control the
"rendered" attribute of the listbox.
<h:selectBooleanCheckbox value="#{someBean.listBoxEnabled}"/>
<h:selectManyListbox rendered="#{someBean.listBoxEnabled}" ... />
The problem here is that you need some mechanism for submitting the
entire form back to the server when the checkbox value is changed so the
page can be regenerated.
Maybe you can use tomahawk's collapsible panel control instead of the
checkbox/listbox combination, and avoid the whole issue?
Regards,
Simon