2014-11-24 68 views
-1

當我使用下面的代碼時,我得到java.lang.IllegalArgumentException錯誤。我不能在f:屬性中使用jsf 2.0 el表達式嗎?

<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:屬性」。

  1. 我說錯了嗎?
  2. 爲什麼?
  3. 有沒有辦法在f:屬性中使用el?
+0

「F:屬性」標籤允許您將屬性值傳遞到組件,或通過動作偵聽器的參數的組件。 – Scorpion 2014-11-24 12:49:12

+0

'#{toDoItem.title}'是否解析爲'String'? 「」中的每一行是否填有「標題」? – 2014-11-24 13:03:08

+0

您應該顯示您的managedbean。 – wittakarn 2014-11-24 15:53:22

回答

0

您的toDoItemList列表是否有字段標題?如果是的話,標題是否有getter和setter? 還請查看

jsf f:attribute

+0

當然,我的ToDoItem類中有正確的getter和setter。你可以假設我的託管bean和其他類是正確的。 – FranXho 2014-11-25 12:55:29