通常我会做类似下面的事情。单击按钮执行转换。
<!-- 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>
的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... ???
}
}
答案 0 :(得分:4)
我最近遇到了类似的问题,并使用类似的侦听器样式处理primefaces / richfaces事件。这是一个例子:
public void changeListener(AjaxBehaviorEvent event) {
RequestContext requestContext = RequestContextHolder.getRequestContext();
RequestControlContext rec = (RequestControlContext) requestContext;
//place variables you need in next flow phase here; flash,application,session scope
rec.getFlashScope().put("someVarIneedInNextFlow", varName);
rec.handleEvent(new Event(this, "flow transition name here, i.e. next-stage"));
return;
}
那应该转换到你想要的任何流动事件:)