Double-escaped label in SelectOneMenu in PrimeFaces 12

Advertisements

In PrimeFaces’ SelectOneMenu, I use options (often placeholders) like <please select>, loaded from controller via f:selectItems and escaped automatically by the SelectOneMenu component. After updating PrimeFaces 11 to version 12, the component started to double-escape the characters <, >, & in its label, while the option list is still rendered as expected. (When I click <please select>, the label shows &lt;please select&gt;.)

I tried all combinations of these settings:

  • view: f:selectItems.itemLabelEscaped = "true"/"false"
  • controller: SelectItem.escape = "true"/"false"
  • controller: SelectItem.label is/isn’t escaped manually

The attribute itemLabelEscaped has no effect. Other combinations work as follows:

No. SelectItem
.escape
SelectItem.label Option in dropdown Shown label in PF 11 Shown label in PF 12
1 false < <i>italics</i> < italics italics italics
2 false &lt; &lt;i&gt;italics&lt;/i&gt; < <italics> < italics < <italics>
3 true < <i>italics</i> < <italics> < <italics> &lt; &lt;i&gt;italics&lt;/i&gt;
4 true &lt; &lt;i&gt;italics&lt;/i&gt; &lt; &lt;i&gt;italics&lt;/i&gt; &lt; &lt;i&gt;italics&lt;/i&gt; (even more escaped)

In PrimeFaces 11, I used the setting No. 3, and the label was the same as the option in dropdown. After the update, the label gets broken and the only working setting seems to be No. 2, but I don’t want to update all occurrences of selectItems unless necessary.

As I did not find any relevant info in PrimeFaces’ release notes, I would consider it a bug, but I wonder nobody has reported it yet, so I’m not sure: is it a bug, or a feature? This old question seems to be relevant, but how come it worked in PrimeFaces 11?

>Solution :

This is a known and fixed issue. Until PrimeFaces 13 is released, you can MonkeyPatch the workaround.

Leave a ReplyCancel reply