EL is mainly supported / evaluated throughout the Facelet template. Also external tags / attributes. Even in the HTML comments, where many starters then fall. So no problem.
Your specific case, unfortunately, is "by design". Before rendering the first element, <option> <f:selectItems> fully analyzed only once and turns into an iterator, during which all EL expressions will be evaluated. Then the component will iterate over it during the rendering of the <option> elements, during which all transit attributes will be calculated. However, since var already evaluated during the creation of the iterator, it is not available anywhere during the display of forwarding attributes, and ultimately evaluates an empty string.
A fix that will require significant changes to the standard JSF implementation <f:selectItems> . I'm not sure that for the JSF guys, everyone will have ears for you, but you can always try to create a problem .
You can get around this by physically creating multiple instances of <f:selectItem> during the time assembly using <c:forEach> .
<h:selectOneMenu ...> <c:forEach items="#{bean.countries}" var="country"> <f:selectItem itemValue="#{country}" itemLabel="#{country.countryName}" pt:data-icon="flag flag-#{country.isoCode}" /> </c:forEach> </h:selectOneMenu>
See also:
- JSTL in JSF2 Facelets ... makes sense?
Balusc
source share