Friday, August 28, 2009

Render labels correctly with IBM JSF

If you place a jsf component like this on your page:


<h:selectOneRadio disabledClass="selectOneRadio_Disabled"
enabledClass="selectOneRadio_Enabled"
id="selectType"
required="true"
tabindex="11"
value="#{myBean.type}" layout="pageDirection">
<f:selectItems value="#{myBean.selectTypes}" />
</h:selectOneRadio>


You will notice that the labels for the radio buttons in the final html are not generated like you would want them to - the label tag goes around the text and the radio button.

There is a context parameter you can set in the web.xml, so the generation of the html is as expected.


<context-param>
<description>
Set to true to explicitly associate labels with their input elements for select one radio buttons
and select many check box lists.
</description>
<param-name>com.ibm.ws.jsf.associateLabelWithId</param-name>
<param-value>true</param-value>
</context-param>


source : http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rweb_jsf_custom_props.html (new window)

No comments:

Post a Comment