Jsf 删除选定的行数据表
我有以下代码从p:datatable中删除所选行Jsf 删除选定的行数据表,jsf,primefaces,Jsf,Primefaces,我有以下代码从p:datatable中删除所选行 <p:commandLink id="deleteProp" action="#{locationBean.deleteProperty}" styleClass="datatabletext" update="locationProperties" process="@this"> <h:graphicImage value="/resources/images/delete.gif" /> <f:setPro
<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>
我也有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)
它甚至不涉及动作方法。有人能告诉我我犯了什么错误吗
当我将参数传递给delete方法并检查它是否工作时。但是为什么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>
您可以按如下方式执行此操作:
Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String id = params.get("deletingRowId");
LocationPropertiesTO lo = findLObyId(id, locProps);
locProps.remove(selectedProperty);
首先,将所选行的ID传递给Bean,如下所示:
<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" />
<f:param name="deletingRowId" value="#{row.id}" />
</p:commandLink>
最后,更新您的数据表。您可以按如下操作:
Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String id = params.get("deletingRowId");
LocationPropertiesTO lo = findLObyId(id, locProps);
locProps.remove(selectedProperty);
首先,将所选行的ID传递给Bean,如下所示:
<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" />
<f:param name="deletingRowId" value="#{row.id}" />
</p:commandLink>
最后,更新数据表。我认为这与PropertyActionListener中缺少的EL标记有关 尝试使用:
<f:setPropertyActionListener target="#{locationBean.selectedProperty}" value="#{locProp}" />
这就是为什么ELException抱怨试图将字符串值解析到自定义POJO(解析字符串“locProp”)。我认为这与PropertyActionListener中缺少EL标记有关 尝试使用:
<f:setPropertyActionListener target="#{locationBean.selectedProperty}" value="#{locProp}" />
这就是为什么ELException抱怨试图将字符串值解析到自定义POJO中(解析字符串“locProp”)。selectedProperty的类型是什么?LocationProperties是什么类型的selectedProperty?LocationPropertiesTOHi。请查看我的编辑。我想知道f:setPropertyActionListener失败的原因Seems
logicalYes我已经给出了。嗨。请查看我的编辑。我想知道f:setPropertyActionListener失败的原因Seems
logicalYes我已经给出了答案。