Use <ui:param> in a listener into a tag <p:ajax>

别等时光非礼了梦想. 提交于 2019-12-01 06:21:31

The <ui:param> can only pass value expressions, not method expressions.

Better make use of the ability of EL to parameterize method names via brace [] notation. Then you can just declare the method names as plain vanilla String.

<ui:include src="../Componentes/tablaEditable.xhtml">
     ...
     <ui:param name="beanEdicion" value="#{tabla2FuentesHL7}" />
     <ui:param name="aceptarEdicion" value="onRowEdit" />
     <ui:param name="cancelarEdicion" value="onRowCancel" />
</ui:include>
<p:ajax event="rowEdit" listener="#{beanEdicion[aceptarEdicion]()}"  />
<p:ajax event="rowEditCancel" listener="#{beanEdicion[cancelarEdicion]()}"  />

Update as per the comments, it appears to still not work in PrimeFaces 5.1 even though the related issue says that it's already fixed in 3.5. You'd basically need to reopen the issue.

In the meanwhile, you can workaround this with help of <o:methodParam> tag of JSF utility library OmniFaces. This basically converts a value expression to a method expression:

<ui:include src="../Componentes/tablaEditable.xhtml">
         ...
     <ui:param name="aceptarEdicion" value="#{tabla2FuentesHL7.onRowEdit}" />
     <ui:param name="cancelarEdicion" value="#{tabla2FuentesHL7.onRowCancel}" />
</ui:include>
<o:methodParam name="aceptarEdicionParam" value="#{aceptarEdicion}" />
<o:methodParam name="cancelarEdicionParam" value="#{cancelarEdicion}" />
...
<p:ajax event="rowEdit" listener="#{aceptarEdicionParam}"  />
<p:ajax event="rowEditCancel" listener="#{cancelarEdicionParam}"  />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!