I had the same problem and found out that this is because my action method actually threw IllegalArgumentException. In the meantime, this was reported as an error: The composite action method throws a PropertyNotFoundException when the method throws any exception .
The hard part (at least for me) was that my application worked fine until I moved part of the code to a composite component (CC). Before my application caught the IAE and displayed a good error message, but when using CC, a JSF check (or something else ...) will catch this first and create this rather confusing error message.
I checked this using a modified version of the test code provided by BalusC (see below). The test page shows two components of the enter and submit buttons. If you enter something into the text field (except for "panic" (without quotes)), both the CC version and the "built-in" version work (see the output of std). If you introduce a “panic” into the “embedded” version, you will see the IAE as expected, but if you introduce the same thing into the upper “CC version”, you will see a PropertyNotFoundException instead. It seems that the JSF is confused by the IAE and decides that the attribute should be a property, not an action method ... Not sure if this is an error or function. This is according to Spec, does anyone know?
So, the conclusion here is that you cannot use action methods in CC with beans that throw exceptions. For me, this means that I cannot use composite components. Sad
Hope this helps ...
/resources/components/test.xhtml <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:cc="http://java.sun.com/jsf/composite"> <cc:interface> <cc:attribute name="text"/> <cc:attribute name="action" method-signature="java.lang.String action()" required="true" /> </cc:interface> <cc:implementation> <h:form> <h:inputText value="#{cc.attrs.text}"/> <h:commandButton value="submit" action="#{cc.attrs.action}" /> </h:form> </cc:implementation>
/test.xhtml <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:cc="http://java.sun.com/jsf/composite/components"> <h:head> <title>Test</title> </h:head> <h:body> <cc:test text="#{bean.text}" action="#{bean.submit}" /> <hr/> <h:form id="inline"> <h:inputText value="#{bean.text}"/> <h:commandButton value="submit2" action="#{bean.submit}" /> </h:form> </h:body> </html>
And the last Bean:
@ManagedBean @RequestScoped public class Bean { private String text; public String getText() { return text; } public void setText(String text) { this.text = text; } public String submit() { if (text.equalsIgnoreCase("panic")){ throw new IllegalArgumentException("Panic!"); } System.out.println(text); return null; } }
source share