I have the following code to delete the selected row from p:datatable
<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>
Bean code
public void deleteProperty() {
System.out.println("selec "+selectedProperty);
locProps.remove(selectedProperty);
}
I have the getter and setter for selectedProperty too. But when I click the delete link I see the following error.
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)
It doesn't even go to the action method. Can anyone please let me know what mistake I am making?
When I pass argument to delete method and check it is working. But why is f:setPropertyActionListener failing?
Working code
<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>