myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Beat Herlig <beat.her...@comerge.net>
Subject [Trinidad] HTML Code in Radio-Button Labels
Date Wed, 30 Mar 2011 11:15:33 GMT

Hi Everyone,

I'm trying to get some HTML code into the label of my radio buttons. In 
my application, the labels of the radio buttons are quite long, so I 
want to
- insert a <br/> tag
- decorate different parts with some <span> tags (and later apply CSS).

Normally I'd just set the "escape" attribute of the <f:selectItem> 
component to "false", but unfortunately it seems not to work when used 
with a <tr:selectOneRadio> component. And I can't use <tr:selectItem>, 
as it doesn't support the "escape" attribute.

Here's an excerpt from my code:

> <tr:selectOneRadio id="resChoiceId" value="#{myReservationsBean.selectedRes}">
> 	<c:forEach items="#{myReservationsBean.myReservationsList}" var="res">
> 		<f:selectItem itemValue="#{res}" itemLabel="#{res.label}" escape="false"/>
> 	</c:forEach>
> </tr:selectOneRadio>


As I can't put angled brackets directly into the xhtml file (xml 
validation would fail), I'm using a method on the bean objects. In my 
example, this is simply:

> public String getLabel() {
> 	return "foo <br/> bar";
> }

Alas, the rendered code shows that the <br> tag was escaped, and the 
browser doesn't render a break.

> <td valign="top" nowrap class="AFContentCell">
>       <!--Start: org.apache.myfaces.trinidad.SelectOne["resChoiceId"]-->
>       <span id="j_id676284476_4a7fdd17:resChoiceId" class="af_selectOneRadio_content">
>             <input type="radio" name="j_id676284476_4a7fdd17:resChoiceId" id="j_id676284476_4a7fdd17:resChoiceId:_0"
value="0">
>             <label for="j_id676284476_4a7fdd17:resChoiceId:_0">foo &lt;br/&gt;
bar</label>
>             <br>
>             <input type="radio" name="j_id676284476_4a7fdd17:resChoiceId" id="j_id676284476_4a7fdd17:resChoiceId:_1"
value="1">
>             <label for="j_id676284476_4a7fdd17:resChoiceId:_1">foo &lt;br/&gt;
bar</label>
>       </span>
> </td>


Can anyone confirm this behaviour, or is there something I've done 
wrong? Also: is there any other solution to get HTML code into the radio 
button labels (in general, not only a newline tag)?


Thanks,
	Beat


Mime
View raw message