如何在 h:selectOneMenu 中的值更改时执行转换?
通常我会做如下的事情。单击按钮执行转换。
<!-- view -->
<h:form>
<h:commandButton action="doit">
<f:ajax render="@form"/>
</h:commandButton>
</h:form>
<!-- flow -->
<transition on="doit">...</transition>
如何在(例如) h:selectOneMenu 中的更改值上触发转换?
<h:form>
<h:selectOneMenu value="#{selected}">
<f:selectItems value="#{items}/>
<f:ajax event="valueChange" render="@form" />
</h:selectOneMenu>
</h:form>
编辑: 我考虑过将侦听器注册到 f:ajax 并准备 webflow 事件,但如何使用该事件...?有人帮忙吗?
<h:form>
<h:selectOneMenu value="#{selected}">
<f:selectItems value="#{items}/>
<f:ajax event="valueChange" render="@form" listener="#{bean.changeListener}" />
</h:selectOneMenu>
</h:form>
爪哇:
import javax.faces.event.AjaxBehaviorEvent;
import org.springframework.webflow.execution.Event;
public class Bean {
public void changeListener(AjaxBehaviorEvent event) {
// prepare webflow event
Event e = new Event(event.getSource(), "doit");
// propagate this event... ???
}
}
Usually i do something like below. Clicking button execute transition.
<!-- view -->
<h:form>
<h:commandButton action="doit">
<f:ajax render="@form"/>
</h:commandButton>
</h:form>
<!-- flow -->
<transition on="doit">...</transition>
How to fire a transition on change value in (for example) h:selectOneMenu ?
<h:form>
<h:selectOneMenu value="#{selected}">
<f:selectItems value="#{items}/>
<f:ajax event="valueChange" render="@form" />
</h:selectOneMenu>
</h:form>
Edit:
I thought about registering listener to f:ajax and prepare webflow event, but how to use that event... ? Anybody help ?
<h:form>
<h:selectOneMenu value="#{selected}">
<f:selectItems value="#{items}/>
<f:ajax event="valueChange" render="@form" listener="#{bean.changeListener}" />
</h:selectOneMenu>
</h:form>
java:
import javax.faces.event.AjaxBehaviorEvent;
import org.springframework.webflow.execution.Event;
public class Bean {
public void changeListener(AjaxBehaviorEvent event) {
// prepare webflow event
Event e = new Event(event.getSource(), "doit");
// propagate this event... ???
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近遇到了类似的问题,并使用类似的侦听器风格处理 primefaces/richfaces 事件。这是一个示例:
这应该转换到您想要的任何流程事件:)
I recently had a similar issue, and handle primefaces/richfaces events with a similar listener style. Here's an example:
That should transition to whichever flow event you desire :)