为什么EL给我错误的对象作为括号之间的参数?

时间:2022-05-25 20:00:46

Here's the situation:

这是情况:

In a rich:dataTable in an a4j:form, i create a a4j:commandLink to select the values and pass it to the bean with the jboss el action syntax

在a4j:form中的rich:dataTable中,我创建了a4j:commandLink来选择值并使用jboss el action语法将其传递给bean

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

This works without problem.

这没有问题。

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

但是,如果我重新渲染表单以使用ajax调用过滤数据表,当我选择该值时,它会给出错误的结果:来自选择的索引,但来自过滤之前的数据。

Any ideas?

Thank you Zack for giving me the right solution in only 5 minutes.

谢谢Zack在5分钟内给我正确的解决方案。

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

我认为在括号之间的动作中传递参数更优雅,但是,嘿:这是有效的。 :)

Thank you a lot.

非常感谢。

P.s. I'm editing the title too.

附:我也在编辑标题。

4 个解决方案

#1


Try using:

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

and then access that parameter in your action via the requestParameter("myparameter") through the FacesContext.

然后通过FacesContext通过requestParameter(“myparameter”)访问您的操作中的该参数。

As a side-note, this isn't jboss EL, it's unified expression language (EL). It's just a feature of JSP/JSF in general, as specified by Sun.

作为旁注,这不是jboss EL,它是统一表达语言(EL)。它只是JSP / JSF的一个特性,正如Sun所指定的那样。

#2


In addition to the Zack's answer, I would say that if you need to extend the EL expressions in order to have the ability to call method with parameters, you can use the EL Functors library:

除了Zack的答案之外,我想说如果你需要扩展EL表达式以便能够使用参数调用方法,你可以使用EL Functors库:

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

#3


Is your datatable populated using a Collection annotated with @DataModel ? If so try removing it from the context when filtering so that it gets re-requested.

是否使用使用@DataModel注释的Collection填充数据表?如果是这样,请尝试在过滤时将其从上下文中删除,以便重新请求它。

eg.

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

#4


Putting the dataTable in a <a4j:region> worked for me. This way, you can still use JBoss EL parameters.

将dataTable放在 中为我工作。这样,您仍然可以使用JBoss EL参数。

#1


Try using:

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

and then access that parameter in your action via the requestParameter("myparameter") through the FacesContext.

然后通过FacesContext通过requestParameter(“myparameter”)访问您的操作中的该参数。

As a side-note, this isn't jboss EL, it's unified expression language (EL). It's just a feature of JSP/JSF in general, as specified by Sun.

作为旁注,这不是jboss EL,它是统一表达语言(EL)。它只是JSP / JSF的一个特性,正如Sun所指定的那样。

#2


In addition to the Zack's answer, I would say that if you need to extend the EL expressions in order to have the ability to call method with parameters, you can use the EL Functors library:

除了Zack的答案之外,我想说如果你需要扩展EL表达式以便能够使用参数调用方法,你可以使用EL Functors库:

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

#3


Is your datatable populated using a Collection annotated with @DataModel ? If so try removing it from the context when filtering so that it gets re-requested.

是否使用使用@DataModel注释的Collection填充数据表?如果是这样,请尝试在过滤时将其从上下文中删除,以便重新请求它。

eg.

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

#4


Putting the dataTable in a <a4j:region> worked for me. This way, you can still use JBoss EL parameters.

将dataTable放在 中为我工作。这样,您仍然可以使用JBoss EL参数。