![Creative The name of the picture]()

Clash Royale CLAN TAG#URR8PPP
inputCalendar forEach calling a exception
I'm receiving an exception with the code below.
<c:forEach var="calculoNotaUnidade" varStatus="counter" items="#{ configuracoesAva.calculoNotaUnidades }">
<tr>
<td>
<t:inputCalendar id="${ counter.count }" value="#{ calculoNotaUnidade.dataFinalizacaoUnidade }" style="z-index:999;" popupButtonStyle="z-index:0;" renderAsPopup="true" renderPopupButtonAsImage="true" size="10" onkeypress="return (formataData(this,event));" maxlength="10" title="Data de Finalização">
<f:convertDateTime pattern="dd/MM/yyyy" />
</t:inputCalendar>
</td>
</tr>
</c:forEach>
The exception is:

The exception it is called because my inputCalendar ID is wrong (and I don't know how to fix it).
When I don't put any ID, the page is loaded, but the inputCalendars doesn't work.
inputCalendars
This question has not received enough attention.
3 Answers
3
try this id="id_<c:out value="${counter.count}"/>"
id="id_<c:out value="${counter.count}"/>"
JSF does not accept expression variable to set the ID. By the time that JSF prepares the HTML, it should already have the value available to generate the HTML, which is obviously not this case.
BTW, you shouldn't need to include the ID manually to set the index. JSF will do it automatically for you, for example this snippet:
<ui:repeat id="test" value="#{bean.collection}" var="item">
<p:inputText id"testInput" value="#{bean.inputValue}"/>
</ui:repeat>
The HTML generated will be like this (assuming that the variable bean.collection has 3 records):
<input id="id:0:testInput"></input>
<input id="id:1:testInput"></input>
<input id="id:2:testInput"></input>
As you can see, the index is already appended to the HTML id, so this means that you actually does not need the logic you are trying to apply, because JSF does this automatically for you.
I'm pretty sure your jstl c:foreach is not working looking at your stacktrace. Try to get that worling by e.g. looking at the namespace etc . And iven if you do get it working, your ID's cannot start with a digit. Prepend them with an allowed prefix.
c:foreach
id="c_${counter.count}"
and try a # instead of an $
See also:
"c_${counter.count}"
#
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Stacktraces in text please, not images
– Kukeltje
Jul 19 at 6:16