You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Mike Kienenberger <mk...@gmail.com> on 2006/08/19 05:54:47 UTC

onclick support for radio buttons

I needed onclick support for radio buttons.

I wasn't entirely certain how to go about this since I haven't done
much with renderers up to this point, especially adding to the
extended renderers.

I decided to add it to the t:radio component rather than try to create
a t:selectItem component from scratch.

Then in tomahawk:org.apache.myfaces.renderkit.html.ext.HtmlRadioRenderer.renderRadio(),
I call this method before calling the shared renderRadio method:

    	uiSelectOne.getAttributes().put(HTML.ONCLICK_ATTR,
radio.getAttributes().get(HTML.ONCLICK_ATTR));

Basically, I copy the onclick attribute value from the t:radio to the
t:selectOneRadio (UISelectOne) component.   This seems like a poor
idea, although it is working.   I'd imagine at minimum that I'm
overwriting any existing onclick values, and probably causing the new
value to be saved as the UISelectOne's state.

It seems to me that all of this would work better if
org.apache.myfaces.shared.renderkit.html.renderRadio() took a
SelectItem argument rather than the "label + value + disabled +
checked + id" pieces from a SelectItem.   The method renders all of
the UISelectOne passthrough items already, so the trick is being able
to specify all of these pass-through items per line if they exist on a
particular SelectItem.

Any thoughts on this?