Pass a parameter inside <f:event listener="#{myBean.retrieveData(#{})">
java, jsf, jsf-2
Solution
You can pass it through attribute.
Here is what I do on JSF:
<f:metadata>
<f:event listener="#{myBean.retrieveData}" type="preRenderView" id="fevent"/>
<f:attribute name="myid" value="#{anotherBean.id)" />
</f:metadata>
Meanwhile the managed bean (myBean) is as follow:
public void retrieveData(ComponentSystemEvent event) {
String id = (String) event.getComponent().getAttributes().get("myid");
}
Make sure not to use '()' when calling the managed bean's method on listener of f:event tag.
Problem
I need to populate one datatable using database dynamically in which i need to call a retieveData() method and pass a id to criteria my result inside the method. The parameter that is to be passed is coming from another bean by #{anotherBean.id}. My question is how to pass this parameter inside the method...? Following is what i am trying to do... ``` <f:metadata> <f:event listener="#{myBean.retrieveData(#{anotherBean.id)}" type="preRenderComponent" id="fevent"/> </f:metadata> ```