JSF causes argument type mismatch when binding

I am trying to do the following: When a user enters a value in a component rich:calendar, then he h:inputTextmust have his attribute requiredset to true. I follow the instructions in this post: JSF Control Attributes Using JavaScript

Sorry for creating another post, but I could not figure out how to send the code to the comments area and make it readable. The page is causing this error:

javax.el.ELException: /pages/overtime/overtime-n.xhtml @121,65 binding="#{oc.overtimeDate}": java.lang.IllegalArgumentException: argument type mismatch

The problem is that the binding is inside the loop c:forEach, and I'm trying to use the loop variable for the binding. overtime.overtimeItemsIt is defined as ArrayList<OvertimeComponent>each object OvertimeComponent, having different properties ( overtimeDate, overtimeDateId, id, overtimeHoursetc.).

<c:forEach items="#{overtime.overtimeItems}" var="oc">
  <rich:calendar value="#{oc.overtimeDate}" 
    requiredMessage="Date 1 is required."
    id="#{oc.overtimeDateId}" 
    binding="#{oc.overtimeDate}" 
    required="#{oc.id == 1 ? true : false}">
  </rich:calendar>
  <h:inputText value="#{oc.overtimeHours}" 
    id="#{oc.overtimeHoursId}"
    requiredMessage="Hours is required." 
    required="#{not empty oc.overtimeDate.value}" >
  </h:inputText>
  .....
</c:forEach>

How do I do h:inputTextif an object rich:calendarmatters? There is a way to do this using the bindingcalendar property , but I'm not sure how to do this internally c:forEach. I can not use AJAX for this project. Thank.

+3
source share
2 answers

binding UIComponent, , Date. , c:forEach.

<rich:calendar value="#{oc.overtimeDate}" 
    requiredMessage="Date 1 is required."
    id="#{oc.overtimeDateId}" 
    binding="#{calendarComponent}" 
    required="#{oc.id == 1 ? true : false}">
</rich:calendar>
<h:inputText value="#{oc.overtimeHours}" 
    id="#{oc.overtimeHoursId}"
    requiredMessage="Hours is required." 
    required="#{not empty calendarComponent.value}" >
</h:inputText>

" ", bean, bean. #{calendarComponent} , . .

c:forEach, ui:repeat, ( ui:repeat HTML). , . , . UIComponent ( , UIInput) , oc, , . .

public class OvertimeComponent {
    private UIInput calendarComponent;
    // ...

<rich:calendar value="#{oc.overtimeDate}" 
    requiredMessage="Date 1 is required."
    id="#{oc.overtimeDateId}" 
    binding="#{oc.calendarComponent}" 
    required="#{oc.id == 1}">
</rich:calendar>
<h:inputText value="#{oc.overtimeHours}" 
    id="#{oc.overtimeHoursId}"
    requiredMessage="Hours is required." 
    required="#{not empty oc.calendarComponent.value}" >
</h:inputText>

( , EL required rich:calendar, boolean)

+2

, el? richfaces .

, ui: repeat c: foreach?

http://www.ilikespam.com/blog/c:foreach-vs-ui:repeat-in-facelets

c: foreach, , facelets, jsf jsp. .

+1

Source: https://habr.com/ru/post/1777539/


All Articles