You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Wendy Chou <ci...@gmail.com> on 2007/01/12 00:04:04 UTC
How to overwrite default renderer for to include "for" attribute in
Hi,
I would like to render radio buttons differently to include the "for"
attribute in the label tag. So when I do this:
<h:selectOneRadio>
<f:selectItem value="#{bean.options}" />
</h:selectOneRadio>
I want this set of radio buttons would render like so:
<label for="radio1">
<input type="radio" id="radio1" value="Y" />Yes
</label>
<label for="radio2">
<input type="radio" id="radio2" value="N" />No
</label>
Currently I have extended the HtmlRadioRenderer class in the
org.apache.myfaces.renderkit.html.ext package. However I'm not sure how to
configure my faces-config so that all <h:selectOneRadio> tags would use my
extended renderer.
My main concerns are the <component-family> and <render-type> tags, as I'm
not sure what values to set them to. I tried doing:
<renderer>
<component-family>myRadio</component-family>
<renderer-type>org.apache.myfaces.Radio</renderer-type>
<renderer-class>com.my.example.extendedHtmlRadioRenderer
</renderer-class>
</renderer>
and
<renderer>
<component-family>myRadio</component-family>
<renderer-type>javax.faces.Radio</renderer-type>
<renderer-class>com.my.example.extendedHtmlRadioRenderer
</renderer-class>
</renderer>
but none worked.
Has anyone already gotten this to work, or perhaps can someone give me
suggestions as to what I should try?
Thanks!!
Re: How to overwrite default renderer for to include "for" attribute in
Posted by Wendy Chou <ci...@gmail.com>.
Ok, then maybe I am not extending the correct renderer? Currently, my
renderer extends org.apache.myfaces.renderkit.html.ext.HtmlRadioRenderer.
There is however another HtmlRadioRenderer in the package
org.apache.myfaces.renderkit.html but the class body is empty. These are the
only 2 HtmlRadioRenderer source files in my project jars.
Is org.apache.myfaces.renderkit.html.ext.HtmlRadioRenderer the correct
render to extend from?
Thanks.
On 1/12/07, Cagatay Civici <ca...@gmail.com> wrote:
>
> Hi,
>
> I looked in the myfaces-api-1.1.5-SNAPSHOT-sources.jar and
> > myfaces-impl-1.1.5-SNAPSHOT-sources.jar files but did not find .tld
> > files
> >
> tld files are not in the *-sources jar files, they're in the actual binary
> snapshots itself.
>
> I use facelets in my project and I also did not find taglib.xml files
> > either. How should I go about determining what component the facelet
> > <h:selectOneRadio> tag uses
> >
> There's no need to provide a taglib.xml for jsf core and html libs since
> facelets is aware of these by default.
>
> Simon's suggestion for h:selectOneMenu;
>
> <renderer>
> <component-family>javax.faces.SelectOne</component-family>
> <renderer-type> javax.faces.Radio</renderer-type>
> <renderer-class>com.my.example.extendedHtmlRadioRenderer
> </renderer-class>
> </renderer>
>
> should work for you, also note that for t:selectOneRadio has another
> renderer-type: org.apache.myfaces.Radio
>
> On 1/12/07, Wendy Chou <ci...@gmail.com> wrote:
> >
> > Thanks for your reply Simon.
> >
> > I tried what you suggested, however it didn't seem to work. I looked in
> > the myfaces-api-1.1.5-SNAPSHOT-sources.jar and
> > myfaces-impl-1.1.5-SNAPSHOT-sources.jar files but did not find .tld
> > files. I use facelets in my project and I also did not find taglib.xmlfiles either. How should I go about determining what component the facelet
> > <h:selectOneRadio> tag uses? And what exactly are the names of the
> > configuration files that I should be looking for?
> >
> > Any help would be much appreciated!!
> >
> >
> >
> > On 1/11/07, Simon Kitching < simon.kitching@rhe.co.nz> wrote:
> > >
> > > Wendy Chou wrote:
> > > > Hi,
> > > >
> > > > I would like to render radio buttons differently to include the
> > > "for"
> > > > attribute in the label tag. So when I do this:
> > > >
> > > > <h:selectOneRadio>
> > > > <f:selectItem value="#{bean.options}" />
> > > > </h:selectOneRadio>
> > > >
> > > > I want this set of radio buttons would render like so:
> > > >
> > > > <label for="radio1">
> > > > <input type="radio" id="radio1" value="Y" />Yes
> > > > </label>
> > > > <label for="radio2">
> > > > <input type="radio" id="radio2" value="N" />No
> > > > </label>
> > > >
> > > > Currently I have extended the HtmlRadioRenderer class in the
> > > > org.apache.myfaces.renderkit.html.ext package. However I'm not sure
> > > how
> > > > to configure my faces-config so that all <h:selectOneRadio> tags
> > > would
> > > > use my extended renderer.
> > > >
> > > > My main concerns are the <component-family> and <render-type> tags,
> > > as
> > > > I'm not sure what values to set them to. I tried doing:
> > > >
> > > > <renderer>
> > > > <component-family>myRadio</component-family>
> > > > <renderer-type>org.apache.myfaces.Radio</renderer-type>
> > > >
> > > > <renderer-class>com.my.example.extendedHtmlRadioRenderer</renderer-class>
> > > > </renderer>
> > > >
> > > > and
> > > >
> > > > <renderer>
> > > > <component-family>myRadio</component-family>
> > > > <renderer-type> javax.faces.Radio</renderer-type>
> > > >
> > > > <renderer-class>com.my.example.extendedHtmlRadioRenderer
> > > </renderer-class>
> > > > </renderer>
> > > >
> > > > but none worked.
> > > >
> > > > Has anyone already gotten this to work, or perhaps can someone give
> > > me
> > > > suggestions as to what I should try?
> > >
> > > As can be seen in the .tld file, h:selectOneRadio is handled by
> > > org.apache.myfaces.taglib.html.HtmlSelectOneRadioTag.
> > >
> > > This tag class shows clearly that it uses renderer-type of
> > > "javax.faces.Radio".
> > >
> > > The actual component type is javax.faces.HtmlSelectOneRadio, and
> > > inherits its COMPONENT_FAMILY from parent class UISelectOne, which
> > > defines it as "javax.faces.SelectOne ".
> > >
> > > So:
> > > <renderer>
> > > <component-family>javax.faces.SelectOne</component-family>
> > > <renderer-type>javax.faces.Radio</renderer-type>
> > > <renderer-class>....</renderer-class>
> > > </renderer>
> > > should work for you.
> > >
> > > Regards,
> > >
> > > Simon
> > >
> >
> >
>
Re: How to overwrite default renderer for to include "for" attribute in
Posted by Cagatay Civici <ca...@gmail.com>.
Hi,
I looked in the myfaces-api-1.1.5-SNAPSHOT-sources.jar and
> myfaces-impl-1.1.5-SNAPSHOT-sources.jar files but did not find .tld files
>
tld files are not in the *-sources jar files, they're in the actual binary
snapshots itself.
I use facelets in my project and I also did not find taglib.xml files
> either. How should I go about determining what component the facelet
> <h:selectOneRadio> tag uses
>
There's no need to provide a taglib.xml for jsf core and html libs since
facelets is aware of these by default.
Simon's suggestion for h:selectOneMenu;
<renderer>
<component-family>javax.faces.SelectOne</component-family>
<renderer-type>javax.faces.Radio</renderer-type>
<renderer-class>com.my.example.extendedHtmlRadioRenderer
</renderer-class>
</renderer>
should work for you, also note that for t:selectOneRadio has another
renderer-type: org.apache.myfaces.Radio
On 1/12/07, Wendy Chou <ci...@gmail.com> wrote:
>
> Thanks for your reply Simon.
>
> I tried what you suggested, however it didn't seem to work. I looked in
> the myfaces-api-1.1.5-SNAPSHOT-sources.jar and
> myfaces-impl-1.1.5-SNAPSHOT-sources.jar files but did not find .tld files.
> I use facelets in my project and I also did not find taglib.xml files
> either. How should I go about determining what component the facelet
> <h:selectOneRadio> tag uses? And what exactly are the names of the
> configuration files that I should be looking for?
>
> Any help would be much appreciated!!
>
>
>
> On 1/11/07, Simon Kitching <si...@rhe.co.nz> wrote:
> >
> > Wendy Chou wrote:
> > > Hi,
> > >
> > > I would like to render radio buttons differently to include the "for"
> > > attribute in the label tag. So when I do this:
> > >
> > > <h:selectOneRadio>
> > > <f:selectItem value="#{bean.options}" />
> > > </h:selectOneRadio>
> > >
> > > I want this set of radio buttons would render like so:
> > >
> > > <label for="radio1">
> > > <input type="radio" id="radio1" value="Y" />Yes
> > > </label>
> > > <label for="radio2">
> > > <input type="radio" id="radio2" value="N" />No
> > > </label>
> > >
> > > Currently I have extended the HtmlRadioRenderer class in the
> > > org.apache.myfaces.renderkit.html.ext package. However I'm not sure
> > how
> > > to configure my faces-config so that all <h:selectOneRadio> tags would
> >
> > > use my extended renderer.
> > >
> > > My main concerns are the <component-family> and <render-type> tags, as
> > > I'm not sure what values to set them to. I tried doing:
> > >
> > > <renderer>
> > > <component-family>myRadio</component-family>
> > > <renderer-type>org.apache.myfaces.Radio</renderer-type>
> > >
> > > <renderer-class>com.my.example.extendedHtmlRadioRenderer</renderer-class>
> > > </renderer>
> > >
> > > and
> > >
> > > <renderer>
> > > <component-family>myRadio</component-family>
> > > <renderer-type> javax.faces.Radio</renderer-type>
> > >
> > > <renderer-class>com.my.example.extendedHtmlRadioRenderer
> > </renderer-class>
> > > </renderer>
> > >
> > > but none worked.
> > >
> > > Has anyone already gotten this to work, or perhaps can someone give me
> >
> > > suggestions as to what I should try?
> >
> > As can be seen in the .tld file, h:selectOneRadio is handled by
> > org.apache.myfaces.taglib.html.HtmlSelectOneRadioTag.
> >
> > This tag class shows clearly that it uses renderer-type of
> > "javax.faces.Radio".
> >
> > The actual component type is javax.faces.HtmlSelectOneRadio, and
> > inherits its COMPONENT_FAMILY from parent class UISelectOne, which
> > defines it as "javax.faces.SelectOne ".
> >
> > So:
> > <renderer>
> > <component-family>javax.faces.SelectOne</component-family>
> > <renderer-type>javax.faces.Radio</renderer-type>
> > <renderer-class>....</renderer-class>
> > </renderer>
> > should work for you.
> >
> > Regards,
> >
> > Simon
> >
>
>
Re: How to overwrite default renderer for to include "for" attribute in
Posted by Wendy Chou <ci...@gmail.com>.
Thanks for your reply Simon.
I tried what you suggested, however it didn't seem to work. I looked in the
myfaces-api-1.1.5-SNAPSHOT-sources.jar and
myfaces-impl-1.1.5-SNAPSHOT-sources.jar files but did not find .tld files. I
use facelets in my project and I also did not find taglib.xml files either.
How should I go about determining what component the facelet
<h:selectOneRadio> tag uses? And what exactly are the names of the
configuration files that I should be looking for?
Any help would be much appreciated!!
On 1/11/07, Simon Kitching <si...@rhe.co.nz> wrote:
>
> Wendy Chou wrote:
> > Hi,
> >
> > I would like to render radio buttons differently to include the "for"
> > attribute in the label tag. So when I do this:
> >
> > <h:selectOneRadio>
> > <f:selectItem value="#{bean.options}" />
> > </h:selectOneRadio>
> >
> > I want this set of radio buttons would render like so:
> >
> > <label for="radio1">
> > <input type="radio" id="radio1" value="Y" />Yes
> > </label>
> > <label for="radio2">
> > <input type="radio" id="radio2" value="N" />No
> > </label>
> >
> > Currently I have extended the HtmlRadioRenderer class in the
> > org.apache.myfaces.renderkit.html.ext package. However I'm not sure how
> > to configure my faces-config so that all <h:selectOneRadio> tags would
> > use my extended renderer.
> >
> > My main concerns are the <component-family> and <render-type> tags, as
> > I'm not sure what values to set them to. I tried doing:
> >
> > <renderer>
> > <component-family>myRadio</component-family>
> > <renderer-type>org.apache.myfaces.Radio</renderer-type>
> >
> > <renderer-class>com.my.example.extendedHtmlRadioRenderer
> </renderer-class>
> > </renderer>
> >
> > and
> >
> > <renderer>
> > <component-family>myRadio</component-family>
> > <renderer-type>javax.faces.Radio</renderer-type>
> >
> > <renderer-class>com.my.example.extendedHtmlRadioRenderer
> </renderer-class>
> > </renderer>
> >
> > but none worked.
> >
> > Has anyone already gotten this to work, or perhaps can someone give me
> > suggestions as to what I should try?
>
> As can be seen in the .tld file, h:selectOneRadio is handled by
> org.apache.myfaces.taglib.html.HtmlSelectOneRadioTag.
>
> This tag class shows clearly that it uses renderer-type of
> "javax.faces.Radio".
>
> The actual component type is javax.faces.HtmlSelectOneRadio, and
> inherits its COMPONENT_FAMILY from parent class UISelectOne, which
> defines it as "javax.faces.SelectOne".
>
> So:
> <renderer>
> <component-family>javax.faces.SelectOne</component-family>
> <renderer-type>javax.faces.Radio</renderer-type>
> <renderer-class>....</renderer-class>
> </renderer>
> should work for you.
>
> Regards,
>
> Simon
>
Re: How to overwrite default renderer for to include
"for" attribute in
Posted by Simon Kitching <si...@rhe.co.nz>.
Wendy Chou wrote:
> Hi,
>
> I would like to render radio buttons differently to include the "for"
> attribute in the label tag. So when I do this:
>
> <h:selectOneRadio>
> <f:selectItem value="#{bean.options}" />
> </h:selectOneRadio>
>
> I want this set of radio buttons would render like so:
>
> <label for="radio1">
> <input type="radio" id="radio1" value="Y" />Yes
> </label>
> <label for="radio2">
> <input type="radio" id="radio2" value="N" />No
> </label>
>
> Currently I have extended the HtmlRadioRenderer class in the
> org.apache.myfaces.renderkit.html.ext package. However I'm not sure how
> to configure my faces-config so that all <h:selectOneRadio> tags would
> use my extended renderer.
>
> My main concerns are the <component-family> and <render-type> tags, as
> I'm not sure what values to set them to. I tried doing:
>
> <renderer>
> <component-family>myRadio</component-family>
> <renderer-type>org.apache.myfaces.Radio</renderer-type>
>
> <renderer-class>com.my.example.extendedHtmlRadioRenderer</renderer-class>
> </renderer>
>
> and
>
> <renderer>
> <component-family>myRadio</component-family>
> <renderer-type>javax.faces.Radio</renderer-type>
>
> <renderer-class>com.my.example.extendedHtmlRadioRenderer</renderer-class>
> </renderer>
>
> but none worked.
>
> Has anyone already gotten this to work, or perhaps can someone give me
> suggestions as to what I should try?
As can be seen in the .tld file, h:selectOneRadio is handled by
org.apache.myfaces.taglib.html.HtmlSelectOneRadioTag.
This tag class shows clearly that it uses renderer-type of
"javax.faces.Radio".
The actual component type is javax.faces.HtmlSelectOneRadio, and
inherits its COMPONENT_FAMILY from parent class UISelectOne, which
defines it as "javax.faces.SelectOne".
So:
<renderer>
<component-family>javax.faces.SelectOne</component-family>
<renderer-type>javax.faces.Radio</renderer-type>
<renderer-class>....</renderer-class>
</renderer>
should work for you.
Regards,
Simon