0

My page:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:compo="http://java.sun.com/jsf/composite/test">
    <h:head>
    </h:head>
    <h:body>
        <h:form>
            <compo:composite changeListener="#{testBean.invoke}"/>
        </h:form>
    </h:body>
</html>

My composite component:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

<composite:interface>
    <composite:attribute name="changeListener" required="true"
                         method-signature="java.lang.Object action(javax.faces.event.AjaxBehaviorEvent)"/>
</composite:interface>

<composite:implementation>
    <h:commandButton value="Click">
        <f:ajax event="click" listener="#{cc.attrs.changeListener}"/>
    </h:commandButton>
</composite:implementation>

</html>

My java bean (prototype scope in spring):

public class Bean {

    public void invoke(javax.faces.event.AjaxBehaviorEvent event) {
        // some logic
    }
}

When I trying to press button, I see

02-Jul-2014 01:24:22.242 WARNING [http-apr-8080-exec-43] com.sun.faces.lifecycle.InvokeApplicationPhase.execute 0
 java.lang.ArrayIndexOutOfBoundsException: 0
    at org.apache.el.parser.AstValue.convertArgs(AstValue.java:287)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:241)

in log. For some cases I've got: java.lang.NumberFormatException: For input string: testBean.invoke So, it is JSF bug or I do something wrong? How I can pass method expression inside composite component?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Evgeny Mironenko
  • 389
  • 3
  • 5
  • 26
  • It should be a bug in Mojarra, try the example with Apache MyFaces. – lu4242 Jul 02 '14 at 00:58
  • @lu4242 in my project we use Mojarra JSF, we cannot change it. Could send link to Mojarra ticket please? – Evgeny Mironenko Jul 02 '14 at 09:00
  • I use MyFaces, not Mojarra, so you should create an issue there, but first you need to verify if the issue was already reported or not. The only thing I can do is tell you that the example is valid and show you an alternative solution. This topic was solved long time ago in MyFaces. – lu4242 Jul 03 '14 at 05:08
  • @lu4242 ok, thank you. I will to search it. – Evgeny Mironenko Jul 03 '14 at 09:29

2 Answers2

0

Looks like JSF bug https://java.net/jira/browse/JAVASERVERFACES-2758 Exceptions are different, but if you opens response in browser, you will see PropertyNotFoundException.

Workaround for me: pass not MethodExpression, but bean and methodName separately and execute listener as

listener="#{cc.attrs.bean[cc.attrs.method]}"
Evgeny Mironenko
  • 389
  • 3
  • 5
  • 26
-1

The stack trace it looks like the Apache Expression Language parser form Tomcat (org.apache.el.parser). I think it is this issue: https://bz.apache.org/bugzilla/show_bug.cgi?id=57855 ( Invoke MethodExpression with wrong pram count results in ArrayIndexOutOfBoundsException).