事象 : ui:repeat
に指定したvarStatus
をrendered
に指定したら怒られた
- 環境
- Windows10 Pro バージョン1909
- openjdk version "11" 2018-09-25
- JSF 2.3.9
java.lang.IllegalArgumentException: Cannot convert IterationStatus{index=0, first=true, last=false, begin=null, end=null, step=null, even=true, current=null, iterationCount=0} of type class com.sun.faces.facelets.tag.IterationStatus to class java.lang.Long
at com.sun.el.lang.ELSupport.coerceToNumber(ELSupport.java:272)
at com.sun.el.lang.ELSupport.equals(ELSupport.java:137)
at com.sun.el.parser.AstEqual.getValue(AstEqual.java:36)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
原因 : varStatusはオブジェクトなのにそのままインデックス番号として判定式を書いたから
<ui:repeat var="item" varStatus="status" value="#{itemlist}">
<tr>
<ui:fragment rendered="#{status == 0}">
Name of the exported request scoped variable for the status of the iteration. Object is a POJO with the following read-only JavaBeans properties. This scoped variable has nested visibility.
begin of type Integer
end of type Integer
index of type int
step of type Integer
even of type boolean
odd of type boolean
first of type boolean
last of type boolean
repeat(JSF 2.0 Page Decraration Language: Facelets Variant)
対応 : インデックス番号の判定式を書くときはindexプロパティを使う
<ui:fragment rendered="#{status.index == 0}">