You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by tashagooch <bi...@state.mn.us> on 2007/03/12 17:12:17 UTC

ID

I'm using <t:radio> in conjunction with <t:selectOneRadio>.
However, the id parameter of <t:radio> is getting ignored, i.e., not showing
up in the generated HTML.
I need the id for javascript getElementByID().

What am I doing wrong?
Cheers, tashagooch

-- 
View this message in context: http://www.nabble.com/%3Ct%3Aradio%3E-ID-tf3390475.html#a9437637
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ID

Posted by Mike Kienenberger <mk...@gmail.com>.
Looks like the ability to render the id value is configurable, but
always configured to false.

    protected void renderGroupOrItemRadio(FacesContext facesContext,
                                          UIComponent uiComponent,
SelectItem selectItem,
                                          Object currentValue,
                                          Converter converter, boolean
pageDirectionLayout) throws IOException{
[...]
        renderRadio(facesContext, selectOne, itemStrValue, selectItem
                .getLabel(), itemDisabled, itemChecked, false);
[...]
    }

    protected void renderRadio(FacesContext facesContext,
                               UIInput uiComponent,
                               String value,
                               String label,
                               boolean disabled,
                               boolean checked, boolean renderId)
[...]
        if (renderId) {
            writer.writeAttribute(HTML.ID_ATTR, clientId, null);
        }
[...]

One quick fix would be to create a subclass of
org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRadioRendererBase
(actually, of whatever class that <t:selectOneRadio> uses -- it might
already be another subclass of HtmlRadioRendererBase), and then
override renderRadio() to always return true, either for all
t:selectOneRadio classes or for your own custom my:selectOneRadio tag.
  You'd need to set this new renderer subclass as the renderer for
whichever component in your faces-config.xml file.



    protected void renderRadio(FacesContext facesContext,
                               UIInput uiComponent,
                               String value,
                               String label,
                               boolean disabled,
                               boolean checked, boolean renderId)
{
     return super.renderRadio(facesContext, uiComponent, value, label,
disabled, checked, true);
}

On 3/12/07, tashagooch <bi...@state.mn.us> wrote:
>
> I'm using <t:radio> in conjunction with <t:selectOneRadio>.
> However, the id parameter of <t:radio> is getting ignored, i.e., not showing
> up in the generated HTML.
> I need the id for javascript getElementByID().
>
> What am I doing wrong?
> Cheers, tashagooch
>
> --
> View this message in context: http://www.nabble.com/%3Ct%3Aradio%3E-ID-tf3390475.html#a9437637
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>