2

Well, I have the composite component bellow:

<composite:interface> <composite:attribute name="acaoDestino" required="true" shortDescription="Método que será executado quando o usuário clicar no botão 'Sim'." /> </composite:interface> <composite:implementation> <h:commandButton actionListener="#{cc.attrs.acaoDestino}" class="btn btn-primary" value="Sim"> <f:ajax render="@all" execute="@all" /> </h:commandButton> </composite:implementation> 

When i click in this commandButton an actionListener (acaoDestino) is called twice. In the first call the method runs normal, but in second call i got error:

Jan 31, 2015 7:00:32 PM com.sun.faces.context.AjaxExceptionHandlerImpl handlePartialResponseError Grave: javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.acaoDestino}' at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(Unknown Source) at javax.faces.event.MethodExpressionActionListener.processAction(Unknown Source) at javax.faces.event.ActionEvent.processListener(Unknown Source) at javax.faces.component.UIComponentBase.broadcast(Unknown Source) at javax.faces.component.UICommand.broadcast(Unknown Source) at javax.faces.component.UIViewRoot.broadcastEvents(Unknown Source) at javax.faces.component.UIViewRoot.processApplication(Unknown Source) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(Unknown Source) at com.sun.faces.lifecycle.Phase.doPhase(Unknown Source) at com.sun.faces.lifecycle.LifecycleImpl.execute(Unknown Source) at javax.faces.webapp.FacesServlet.service(Unknown Source) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:72) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at br.com.jwebbuild.filter.LoginFilter.doFilter(LoginFilter.java:73) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) 

Important: I don't expect this actionListener called twice. Another important note is that i'm binding a datatable, i don't know if this can cause this problem.

Edit 1

My acaoDestino is a method in ManagedBean, see:

public void removeSelected() { ... } 

Using directly in commandButton would be like this:

<h:commandButton actionListener="#{myManagedBean.removeSelected()}" class="btn btn-primary" value="Sim"> <f:ajax render="@all" execute="@all" /> </h:commandButton> 

Edit 2 (I'm using JSF 2.2.9)

I edited my attribute acaoDestino putting method-signature

<composite:attribute name="acaoDestino" required="true" method-signature="void actionListener()" shortDescription="Método que será executado quando o usuário clicar no botão 'Sim'." /> 

Now i got the following error:

Advertência: java.lang.IllegalArgumentException: wrong number of arguments javax.el.ELException: java.lang.IllegalArgumentException: wrong number of arguments 

I'm using composite component inside another composite component, look:

<jw:confirmButton acaoDestino="#{cc.attrs.managedBeanName.removeSelected()}" value="Remover Selecionados" /> 

3 Answers 3

2

First, you must specify a method signature so that JSF knows its a method expression and not a value expression, your composite component should look like this:

<composite:interface> <composite:attribute name="acaoDestino" required="true" method-signature="void actionListener()" shortDescription="Método que será executado quando o usuário clicar no botão 'Sim'." /> </composite:interface> <composite:implementation> <h:commandButton actionListener="#{cc.attrs.acaoDestino}" class="btn btn-primary" value="Sim"> <f:ajax render="@all" execute="@all" /> </h:commandButton> </composite:implementation> 

Second, If you are not using EL 2.2 you should use this signature (see JSF - actionListener tag calls method which doesn't take an ActionEvent parameter):

public void removeSelected(ActionEvent e) { ... } 

in that case your method signature attribute become:

method-signature="void actionListener(ActionEvent e) 

NB: Command components submit requests when they are activated, so there is no need to use the <f:ajax render="@all" execute="@all" /> while you are refreshing the entire page.

Sign up to request clarification or add additional context in comments.

5 Comments

didn't work, i edited my post with new informations. I'm using JSF 2.2
@user2776409 please provide how are using your composite component in your xhtml page?
You have to use it like this: <jw:confirmButton acaoDestino="#{managedBeanName.removeSelected}" value="Remover Selecionados" />
please remove the value attribute as you didn't declare it in your CC interface, i am using your same code and its working!
0

Can you tell me about acaoDestino is what exactly ? a method var in your backing bean? because if it's a method or var you have to use in your buttonCommand action="" or listener=""

6 Comments

good so try to use action="emoveSelected" or listener="#{removeSelected"
But i need use 'acaoDestino' and not 'removeSelected()" because the actionListener can change.
whait you say acaoDestino is a method or a field in you bean i wan to means a property in your bean ?
acaoDestino is a "attribute" in composite components for use in composite:implementation.
ok if you don't have listener that means that the version of you jsf is under 2.2 and in taht case you have to use juste action. can you pleaze show that part of your bean where you have that attribute whitch named : acaoDestino and make sur if you have for it , the getters and the setters ?
|
0

Try to use :

<h:commandButton listener="#{myManagedBean.removeSelected()}" class="btn btn-primary" value="Sim"> <f:ajax render="@all" execute="@all" /> </h:commandButton> 

or :

<h:commandButton action="#{myManagedBean.removeSelected()}" class="btn btn-primary" value="Sim"> <f:ajax render="@all" execute="@all" /> </h:commandButton> 

1 Comment

listener attribute don't existis in commandButton JSF and action give me the same problem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.