JSF 2.0を使用しています。実際には、JSF 1.2からJSF 2.0に移行しています。 私はのフォームを持っています。<ui:include>
タグで3つのフォームが含まれています。<ui:include>が複数あり、1つの要求スコープBeanを持つ複数ステップのウィザードフォームで、次のステップに進む方法は?
以下のようなmainPage.xhtml
ページの外観は、
<c:if test="#{myManagedBean.stepRender eq 'firstPage'}">
<ui:include src="/public/firstPage.xhtml"/>
</c:if>
<c:if test="#{myManagedBean.stepRender eq 'secondPage'}">
<ui:include src="/public/secondPage.xhtml"/>
</c:if>
<c:if test="#{myManagedBean.stepRender eq 'thirdPage'}">
<ui:include src="/public/thirdPage.xhtml"/>
</c:if>
firstPage.xhtml
は、いくつかの入力フィールドがあり、action="myManagedBean.continueStepOne"
と1 <h:commandButton>
。
secondPage.xhtml
には、入力フィールドが数個あり、<h:commandButton>
はaction="myManagedBean.continueStepTwo"
です。
thirdPage.xhtml
には、入力フィールド数が少なく、<h:commandButton>
とaction="myManagedBean.continueStepThree"
のフィールドがあります。
すべてのインクルードページに1つのBeanのみを使用し、mainPage.xhtml
ページを使用しました。 Beanはリクエストスコープです。
Beanクラス最初
public String continueStepOneAction(){
== validation logic ==
stepRender="secondPage";
return "mainPage";
}
public String continueStepTwoAction(){
== validation logic ==
stepRender="thirdPage";
return "mainPage";
}
のコードIは、mainPage.xhtml
に要求を送信し、stepRender
値に応じて、それは最初firstPage.xhtml
ある特定のページを含むであろうが。
データを入力してcommandbuttonをクリックすると、continueStepOne
アクションが呼び出されます。検証が成功すると、stepRender
の値が変更されます。それがsecondPage
に等しい場合、secondPage.xhtml
ページが含まれます。 thirdPage
についても同様です。
問題はメソッド呼び出しとナビゲーションが正常に動作しているfirstPage
からsecondPage
に、ですが、私たちは、コマンドボタンをクリックするとsecondPage
で、それはmyManagedBean
の唯一のコンストラクタを呼び出しますし、それがcontinueStepThreeAction()
メソッドを呼び出していません豆の中で。 stepRender
の値のデフォルト値はfirstPage
であるため、firstPage.xhtml
に移動します。
問題がどこにあるのかわかりません。どうすれば解決できますか?
原因は明らかです: 'stepRender'は後続のリクエストで保持されません。しかし、私は、JSF 1.xのためにどのように実装したのでしょうか? – BalusC