今日の私の質問は、h:commandButton
コンポーネントを使用せずに顔のフローを開始することは可能ですか? 私の特定のケースでは、h:selectOneMenu
コンポーネントを使用して、ユーザーが選択した値に基づいて特定のフローを開始したいと考えています。
1 に答える
6
答えはイエスですが、少し調整します。フローに入るには、フロー ID と等しいナビゲーション結果を作成する必要があります。UICommandコンポーネント (h:commandButton や h:commandLink など) はそれを実行できますが、UIInputコンポーネントは実行できません ("action" 属性がありません)。ただし、たとえばValueChangeListenerを使用して、ナビゲーションをプログラムでトリガーすることもできます。
<h:form>
<h:selectOneMenu value="#{requestScope.selectedFlow}">
<f:selectItem itemLabel="--- Select a Flow ---" noSelectionOption="true" />
<f:selectItem itemLabel="Flow A" itemValue="flow-a" />
<f:selectItem itemLabel="Flow B" itemValue="flow-b" />
<f:valueChangeListener type="example.NaviagtionTargetListener" />
<f:ajax execute="@form" render="@all"/>
</h:selectOneMenu>
</h:form>
対応する ValueChangeListener:
public class NaviagtionTargetListener implements ValueChangeListener {
@Override
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
String target = (String) event.getNewValue();
ConfigurableNavigationHandler nh = (ConfigurableNavigationHandler) FacesContext.getCurrentInstance().getApplication().getNavigationHandler();
nh.performNavigation(target);
}
}
GitHub で例を作成し[1]、FacesFlow の使用法についてブログ記事を書きました[2]。
[1] https://github.com/tasel/facesflow-example
[2] http://blog.oio.de/2014/02/12/a-comprehensive-example-of-jsf-faces-flow/
于 2014-02-13T08:21:50.950 に答える