Why is EL giving me the wrong object as a parameter between the brackets?

Here's the situation:

In rich: dataTable in a4j form: i create a4j: commandLink to select values ​​and pass them to bean with jboss el action syntax

action="#{bean.myaction(myparameter)}"

      

This works without issue.

But if I re-render the form to filter the data with an ajax call, when I select the value, it gives me wrong results: index from selection, but data before filtering.

Any ideas?

Thanks to Zach for giving me the correct solution in just 5 minutes.

I think the passing parameter in the action between the brackets is more elegant, but hey: it works. :)

Thank you very much.

Ps I am editing the title too.

+1


a source to share


4 answers


Try using:

<a4j:commandLink action="#{bean.myaction}">
    <f:param name="myparameter" value="paramValue" />
</a4j:commandLink>

      



and then access that parameter in your action via requestParameter("myparameter")

via FacesContext

.

As a side note, this is not jboss EL, it is Unified Expression Language (EL). This is just a feature of JSP / JSF in general as pointed out by Sun.

+2


a source


In addition to Zack's answer, I would say that if you need to extend EL expressions to be able to call a method with parameters, you can use the EL Functors Library :



action="#{bean.myaction$[myparameter].action}"

      

+2


a source


Is your populated datatable with a collection annotated with @DataModel? If so, try removing it from context when filtering so that it is re-requested.

eg.

//In filter method
Contexts.removeFromAllContexts("yourDataModelCollection");

      

0


a source


Using dataTable in <a4j:region>

worked for me. This way you can still use JBoss EL options.

0


a source







All Articles