inputCalendar forEach calling a exception

The name of the pictureThe name of the pictureThe name of the pictureClash 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:



enter image description here



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.





Stacktraces in text please, not images
– Kukeltje
Jul 19 at 6:16





idownvotedbecau.se/imageofcode and idownvotedbecau.se/beingunresponsive
– Kukeltje
10 hours ago




3 Answers
3



try this id="id_<c:out value="${counter.count}"/>"


id="id_<c:out value="${counter.count}"/>"





Creative... Did you try/use something like this before?
– Kukeltje
9 hours ago



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.





Wrong, jsf allows an id to be set IF you do it view create via jstl
– Kukeltje
2 hours ago





The stacktrace says otherwise, let's wait for OP response
– Bonifacio
1 hour ago





That might be because of this component or maybe even that the jstl does not work and the EL is evaluated rendertime. And for JSF in general, including PrimeFaces, you can set an id via jstl at view create time, believe me, I use it in production. And see stackoverflow.com/questions/9147771/…
– Kukeltje
6 mins ago





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:





Same error using "c_${counter.count}".
– FabianoLothor
Jul 19 at 16:57


"c_${counter.count}"





Using # java.lang.IllegalArgumentException: c_#{ counter.count } at javax.faces.component.UIComponentBase.validateId(UIComponentBase.java:555) at javax.faces.component.UIComponentBase.setId(UIComponentBase.java:351) at javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:219) at
– FabianoLothor
Jul 19 at 16:58


#





Well, I thought the error was sort of not completely right, but maybe inputCalendar just does not accept EL at all like the error states.
– Kukeltje
Jul 19 at 18:43





oh and post more of the stacktrace...
– Kukeltje
Jul 19 at 18:50






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.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

415 Unsupported Media Type while sending json file over REST Template

PHP parse/syntax errors; and how to solve them?