How to send parameter in event JSF

1

I have the following event type preRenderView to execute a method before loading the page:

<f:event listener="#{aprobacionFlujoController.preRender}" type="preRenderView" />

I need to send a parameter to that listener, what is the best way to do it? I tried in the following way:

<f:metadata>
    <f:event listener="#{aprobacionFlujoController.preRender}" type="preRenderView" />
    <f:attribute name="myid" value="true" />
</f:metadata>

And in the controller

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

But getAttributes() comes empty.

    
asked by juandej18 21.11.2016 в 23:08
source

1 answer

0

f:attribute only applies to components that extend UIComponent ; f:metadata is not one of them.

What you can do is:

  • If the value is fixed (as it appears in the code), use c:set of JSTL:

  • If passed by parameter define it with f:viewParam :

answered by 22.11.2016 / 00:22
source