有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java不能在f:attribute中使用JSF2.0EL表达式吗?

当我使用以下代码时,我得到了java。lang.IllegalArgumentException错误

   <h:dataTable value="#{toDoBean.toDoItemList}" var="toDoItem" >

        <h:column>
            <h:selectBooleanCheckbox value="#{toDoItem.finsh}"  
                                     valueChangeListener="#{toDoBean.onStatusChange}" 
                                     onchange="submit()"/>
        </h:column>

        <h:column>
            <h:outputText value="#{toDoItem.title}"/>
        </h:column>

        <h:column>
            <h:commandButton value="X" actionListener="#{toDoBean.onDelete}">
                <f:attribute name="id" value="#{toDoItem.title}" />
            </h:commandButton>
        </h:column>
    </h:dataTable>

但是如果我换了

<f:attribute name="id" value="#{toDoItem.title}" /> 

<f:attribute name="id" value="testing" />

然后一切正常

所以我的假设是“我不能将EL与f:attribute一起使用”

  1. 我说得对吗
  2. 为什么?
  3. 有没有办法在f:attribute中使用el

共 (1) 个答案

  1. # 1 楼答案

    您的toDoItemList列表是否具有字段标题?如果是的话,标题中是否有getter和setter? 同时也请复习

    jsf f:attribute