【问题标题】:Can`t I use jsf 2.0 el expression in f:attribute?我不能在 f:attribute 中使用 jsf 2.0 el 表达式吗?
【发布时间】:2015-01-22 04:28:17
【问题描述】:

当我使用以下代码时,出现 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?

【问题讨论】:

  • “f:attribute”标签允许您将属性值传递给组件,或通过动作监听器将参数传递给组件。
  • #{toDoItem.title} 是否解析为String?您的&lt;h:dataTable&gt; 中的每一行是否都填充了title
  • 你应该展示你的 managedbean。
  • yes #{toDoItem.title} 解析为字符串。

标签: java jsf jsf-2 el


【解决方案1】:

你的 toDoItemList 列表是否有字段标题?如果是,标题是否有 getter 和 setter? 也请查看

jsf f:attribute

【讨论】:

  • 当然,我的 ToDoItem 类中有正确的 getter 和 setter。你可以假设我的托管 bean 和其他类是正确的。
猜你喜欢
  • 2013-09-02
  • 1970-01-01
  • 2012-05-23
  • 1970-01-01
  • 2017-07-18
  • 2013-03-20
  • 2012-10-05
  • 2011-09-09
  • 2011-06-24
相关资源
最近更新 更多