I need to populate one dynamic database dynamically in which I ...">

Pass the parameter inside <f: event listener = "# {myBean.retrieveData (# {})">

I need to populate one dynamic database dynamically in which I need to call the retieveData () method and pass the ID to the criterion of my result inside the method. The parameter to be passed comes from another bean using # {anotherBean.id}. My question is how to pass this parameter inside the method ...? The following is what I am trying to do ...

<f:metadata>
     <f:event listener="#{myBean.retrieveData(#{anotherBean.id)}" type="preRenderComponent" id="fevent"/>
</f:metadata> 

      

+3


source to share


2 answers


You can pass it through an attribute.

This is what I am doing in 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) looks like this:

public void retrieveData(ComponentSystemEvent event) {
    String id = (String) event.getComponent().getAttributes().get("myid");
}

      

You cannot use '()' when calling a managed bean method while listening to the f: event tag.

+7


source


Basically

<f:metadata>
     <f:event listener="#{myBean.retrieveData(anotherBean.id)}" type="preRenderComponent" id="fevent"/>
</f:metadata>

      



should do. But why don't you paste anotherBean

in myBean

and get the ID in your Java code? It is usually best to store this logic in your Java code rather than in a view file - xhtml in this case.

+3


source







All Articles