Hello Christian,
Thank you very much! This indeed works. Is there a 'better' or another
approach which I could take? A concrete use-case would be that I want to
iterate over a collection from a bean (not a managed bean) like that:
- ---
<jsp:useBean id="bean" class="de.fhbswf.emaex.web.TestBean"
scope="request"/>
<c:forEach var="testValue" items="${bean.test}" >
<h:outputText value="${testValue.value}" />
</c:forEach>
- ---
In this case it is not possible without saving the value in a variable
created by c:set.
Unfortunately, the <c:forEach> tag does not allow you to specify the
scope; it is always page-scoped. So, by using <c:forEach> you are
forced to use <c:set> to get the value into the request scope. There
are, of course, always alternatives, but the ones that I can think of
are non-trivial. First, you would create a new JSF variable resolver
which accesses the page-scope (not really sure that is possible).
Second, you could write your own forEach tag which puts the 'var' into
the request scope.
Another use-case I have is to manipulate the id's of h:inputText-tags so
that the id in the message which a validator produces can be localized
or simply replaced:
- ---
<f:loadBundle
basename="properties.localization.ui.suppliercreateproduct"
var="createproductBundle"/>
<h:inputText id="${createproductBundle.articlenrID}"
required="true"
value="#{ProductCreator.articlenumber}">
<h:message for="${createproductBundle.articlenrID}"
styleClass="error" />
- ---
So again: could these cases be handled in a better way?
Hmm??? Not exactly sure what you are trying to achieve here. I never
use the standard JSF <h:message> tag because my company has created it's
own UIFieldMessage component which performs internationalization of
screen messages, but we don't modify the field IDs directly, but rather
use these IDs to look up a field name (and message) from a properties file.
Good luck,
Bryan