0

I can't escape selectItems itemLabel to generate an image

Example:

<h:selectOneRadio layout="pageDirection" styleClass="labelWhite" id="logoRadios" value="#{bean.value}" >
 <f:selectItems itemLabelEscaped="false" value="#{imageSources}" var="imgSrc" itemLabel="#{imgSrc}" itemValue="O" />
</h:selectOneRadio>

JAVA:

@Factory("imageSources")

List<SelectItem> imageSourceList= null;

List<Object> allLogos = someService.serviceImplGetAll(var);

imageSourceList= new ArrayList<SelectItem>(allLogos.size());

for(Object value : allLogos)
{

      selectableLogos.add(new SelectItem("<img src=\""+  value.getLogoResource() + "\" /> "));

}

return imageSourceList;

All I get when generated is:

<td>
<input type="radio" name="j_id579:logoRadios" id="j_id579:logoRadios:0" value="<img src=&quot;/img/rfcLogos/fall_1.svg&quot; /> ">
<label for="j_id579:logoRadios:0"> &lt;img src="/img/rfcLogos/fall_1.svg" /&gt; </label>
</td>

The value is wrong I reckon but for now I'm more concerned on the part that it did not render the img src(not picture only text)

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • In mordern JSF it is not needed to use a SelectItem object. You can use plain lists (and the value is 'wrong' because you only pass one parameter to the SelectItem when creating it. Label and value are the same then) – Kukeltje Sep 26 '18 at 13:46
  • Duplicate?: https://stackoverflow.com/questions/3566122/hselectoneradio-containing-images – Kukeltje Sep 26 '18 at 13:47
  • 1
    Possible duplicate of [How to escape f:selectItem itemLabel attribute](https://stackoverflow.com/questions/14238646/how-to-escape-fselectitem-itemlabel-attribute) – Kukeltje Sep 26 '18 at 13:47
  • Thanks for pointing this out! @Kukeltje. I will try the first link. – JI Cabuhat Sep 27 '18 at 03:24

0 Answers0