我有下面的代碼從對刪除選定行:數據表刪除所選行的數據表
<p:commandLink id="deleteProp" action="#{locationBean.deleteProperty}" styleClass="datatabletext" update="locationProperties" process="@this">
<h:graphicImage value="/resources/images/delete.gif" />
<f:setPropertyActionListener target="#{locationBean.selectedProperty}" value="locProp" />
</p:commandLink>
豆代碼
public void deleteProperty() {
System.out.println("selec "+selectedProperty);
locProps.remove(selectedProperty);
}
我有selectedProperty getter和setter了。但是當我點擊刪除鏈接時,我看到以下錯誤。
WARNING: Cannot convert locProp of type class java.lang.String to class TO.LocationPropertiesTO
javax.el.ELException: Cannot convert locProp of type class java.lang.String to class TO.LocationPropertiesTO
at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:416)
它甚至沒有進入操作方法。任何人都可以讓我知道我在做什麼錯誤?
當我通過參數刪除方法,並檢查它正在工作。但爲什麼f:setPropertyActionListener失敗?
工作代碼
<p:commandLink id="deleteProp" rendered="#{fn:length(locationBean.locProps)>1}"
action="#{locationBean.deleteProperty(locProp)}"
styleClass="datatabletext" update="locationProperties"
process="@this">
<h:graphicImage value="/resources/images/delete.gif" />
</p:commandLink>
什麼是selectedProperty的類型? –
LocationPropertiesTO – user2017810