Note that there are some explanatory texts on larger screens.

plurals
  1. POPass actionListener method to commandButton within a component
    primarykey
    data
    text
    <p>first, please forgive my ignorance and inability so use the search engine (i swear i have searched long and often but did not find any satisfying answer to this problem).</p> <p>I have a bean implementing a action-listener compatible method:</p> <pre><code>@ManagedBean(name = "myBean") @ViewScoped class Bean{ public String myAction(ActionEvent event){ ... = event.getComponent().getAttributes().get("something"); } } </code></pre> <p>Then, i have a jsf component like this:</p> <pre><code>&lt;composite:interface&gt; &lt;composite:attribute name="actionBean" required="true"/&gt; &lt;composite:attribute name="actionMethod" method-signature="void myAction(javax.faces.event.ActionEvent)" /&gt; &lt;/composite:interface&gt; &lt;composite:implementation&gt; &lt;h:form&gt; &lt;p:commandButton actionListener="#{cc.attrs.actionBean[cc.attrs.actionMethod]}"&gt; &lt;f:attribute name="something" value="somevalue" /&gt; &lt;/p:commandButton&gt; &lt;/h:form&gt; &lt;/composite:implementation&gt; </code></pre> <p>It is called something like this:</p> <pre><code>&lt;namespace:myComponent actionBean="#{myBean}" actionMethod="myAction" /&gt; </code></pre> <p>I know that this call is not working, and i wonder how to do it right!</p> <p>My main intention is that i want to have a relatively generic jsf-component (would be nice to have it reusable later), that contains a button. On click to this button i want to pass an object (no simple string! in case of string i would just use <code>action="..."</code> and pass it via <code>f:param</code>). With the <code>actionListener</code> method i take the object via <code>event.getComponent().getAttributes().get("something")</code>.</p> <p>I think the signature <code>void myAction(javax.faces.event.ActionEvent)</code> is the problem that breaks passing the related method to the component, isnt it? Is it in general possible to pass method with any argument to jsf components (and if yes, how)?</p> <p>So, i hope there is a possible solution to solve the general problem with altering the above strategy or maybe use something nice and different (in general i prefer not to use any hacks or workarounds, but like to use what is intended by the framework).</p> <p>Thanks if somebody would find the time to point me the way! In case this question already exists, would be nice to get to the related post and have this deleted.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload