0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Cannot convert IterationStatusとなった時の対応方法

Last updated at Posted at 2020-10-26

事象 : ui:repeatに指定したvarStatusrenderedに指定したら怒られた

  • 環境
    • 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}">
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?