Monday, October 8, 2012

Send Parameters to ActionListener and read it programmatically

You can send parameters when invoking ActionListener behavior by adding the f:attribute tag to Action issuer as explained below on commandButton component:

<af:commandButton text="send attribute" id="cb1"    actionListener="#{bean.method1}">    <f:attribute name="param" value="value"/></af:commandButton>

Then you can read  the attribute programmatically inside the method:

 public void method1(ActionEvent actionEvent) {
    String param = (String)actionEvent.getComponent().getAttributes().get("param");