简体   繁体   中英

JSF Not a Valid Method Expression for Richfaces' a4j:ajax listener

I tried to call static methods from my JSF by creating custom EL functions as described here . It worked fine for command links, actions, etc., but when I try to invoke a method in the Richfaces a4j:ajax below:

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
   xmlns:rich="http://richfaces.org/rich" xmlns:s="http://jboss.org/schema/seam/taglib" xmlns:a4j="http://richfaces.org/a4j" xmlns:c="http://java.sun.com/jsp/jstl/core"
   xmlns:utils="http://example.com/utils">
   ...
   <h:outputLink value="#">
           <a4j:ajax event="click" listener="#{reflectionUtils.setValue(entity,property,null)}" />
   ...
</ui:composition>

And the utils.taglib.xml file:

<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" version="2.0">
   <namespace>http://example.com/utils</namespace>

   <!-- ReflectionUtils -->
   <function>
      <function-name>setValue</function-name>
      <function-class>com.example.util.ReflectionUtils</function-class>
      <function-signature>void setValue(java.lang.Object, java.lang.String, java.lang.Object)</function-signature>
   </function>
</facelet-taglib>

I get the following error:

Caused by javax.faces.view.facelets.TagAttributeException with message: "/resources/facelets/input.xhtml @30,145 listener="#{utils:setValue(entity,property,null)}" Not a Valid Method Expression: #{utils:setValue(entity,property,null)}"

Looking through SO I found this answer saying that with jboss-el.jar method calls with paremeters should work. Tried it, nothing changed.

Also found this answer that says that web.xml should be configured to use Servlet 3.0. Tried that too, same result.

So I ask, is there a difference for a4j:ajax listener? How can I get it to work?

Method you used look like action method, not as a listener method. You can use it with a4j:commandLink .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM