JSF2:有没有办法将 a4j:param 与 rich:select 或 h:selectOneMenu 一起使用
是否可以与下拉菜单一起使用,或者它是否也依赖于实现 ActionSource 的父对象(如 f:setPropertyActionLister )?
理想情况下,我会执行如下操作:
<h:selectOneMenu value="#{myCustomBean.selectedItemIndex}">
<f:selectItems value="#{adminLetterAdminBean.missingSettings}" var="n" itemValue="#{n.id}" itemLabel="#{n.name}"/>
<f:setPropertyActionListener value="42" target="#{adminLetterAdminBean.someProperty}" />
<a4j:ajax />
</rich:select>
但是,这不起作用,因为 h:selectOneMenu 没有实现 javax.faces.component.ActionSource。该页面不会呈现,它给了我一个友好的堆栈跟踪来告诉我这种依赖关系。
在 Richfaces 文档中没有看到有关此约束的任何内容,我尝试了以下操作:
<h:selectOneMenu value="#{myCustomBean.selectedItemIndex}">
<f:selectItems value="#{adminLetterAdminBean.missingSettings}" var="n" itemValue="#{n.id}" itemLabel="#{n.name}"/>
<a4j:param assignTo="#{adminLetterAdminBean.someProperty}" value="42" name="randomRequestParamName"/>
<a4j:ajax />
</rich:select>
这不会爆炸,但它也不设置该属性。我想知道是否以类似的方式设置了一个(或多个)属性。
Is it possible to use with dropdown menus or is it also dependent on the parent object implementing ActionSource as the f:setPropertyActionLister is?
Ideally I would have done something like the following:
<h:selectOneMenu value="#{myCustomBean.selectedItemIndex}">
<f:selectItems value="#{adminLetterAdminBean.missingSettings}" var="n" itemValue="#{n.id}" itemLabel="#{n.name}"/>
<f:setPropertyActionListener value="42" target="#{adminLetterAdminBean.someProperty}" />
<a4j:ajax />
</rich:select>
However this does not work because h:selectOneMenu does not implement javax.faces.component.ActionSource. The page does not render and it gives me a friendly stack trace to tell me about this dependency.
Not seeing anything in the Richfaces documentation about this constraint, I tried the following:
<h:selectOneMenu value="#{myCustomBean.selectedItemIndex}">
<f:selectItems value="#{adminLetterAdminBean.missingSettings}" var="n" itemValue="#{n.id}" itemLabel="#{n.name}"/>
<a4j:param assignTo="#{adminLetterAdminBean.someProperty}" value="42" name="randomRequestParamName"/>
<a4j:ajax />
</rich:select>
This does not blow up, but it also does not set the property. I was wondering if there is a set a (or multiple) properties in a similar fashion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
a4j:param 只能嵌套在操作组件内,例如 a4j:commandButon、a4j:commandLink 和 a4j:jsFunction。您还可以将其与标准按钮/链接组件一起使用。
a4j:param can only be nested inside an action component such as a4j:commandButon, a4j:commandLink and a4j:jsFunction. You can also use it with the standard button/link components.
我有一个类似的问题。我的页面必须在自动完成请求完成之前传输有关自动完成的信息。我通过使用 jsFunction 实现了这一点。我的自动完成看起来像:
根据conf.label(conf是一个forEach变量),自动完成方法中的支持bean会获取不同的数据。
此信息的传输由 jsFunction 完成(就在自动完成声明之后):
只是,当用户将焦点放在特定的自动完成上时,将使用绑定到支持 bean 的一个参数执行“sendInfo”。
I had a similiar problem. My page has to transfer information about the autocomplete before the autocomplete request is done. I achieved this by using jsFunction. My autocomplete looks like:
Depending on conf.label (conf is a forEach variable) different data is fetched by the backing bean in the autocomplete method.
The transfer of this information is done by jsFunction (just after the autocomplete declaration):
Just, when the user puts the focus on a specific autocomplete "sendInfo" is executed with one parameter which is bound to the backing bean.