1

JSFを使用していくつかの手順で登録しようとしています。ページをリロードする必要がないため、すべてが f:ajax に基づいています。

「最初のステップを表示」ボタンを押すと、結果が表示されます。「SecondStep」ボタンを押すと、2 番目のステップが表示されます。しかし、「ThirdStep」ボタンを押すと、すべてが消え、ステップがまったく表示されません。「SecondStep」ボタンと「ThirdStep」ボタンに違いはありません。このコードが機能しない理由がわかりません。

html は次のとおりです。

<aside class="block">
    <h:form id="newform"> 
        <h:commandButton value="Show First Step">
            <f:ajax event="action" render="-allContent -firstStepForm" listener="#{stateBean.ajaxShowFirstStep}"></f:ajax>
        </h:commandButton>
    </h:form>

    <h:panelGroup id="allContent">
        <h:panelGroup id="firstStep">
            <ui:fragment rendered="#{stateBean.firstStep}">
                <span>AAAA</span>
                <h:form id="firstStepForm">
                    <h:commandButton value="SecondStep">
                        <f:ajax event="action" render="-allContent  -secondStepForm" listener="#{stateBean.ajaxShowSecondStep}"></f:ajax>
                    </h:commandButton>
                </h:form>
            </ui:fragment>
        </h:panelGroup>

        <h:panelGroup id="secondStep">
            <ui:fragment rendered="#{stateBean.secondStep}">
                <span>BBBB</span>
                <h:form id="secondStepForm">
                    <h:commandButton value="ThirdStep">
                        <f:ajax event="action" render="-allContent  -thirdStepForm" listener="#{stateBean.ajaxShowThirdStep}"></f:ajax>
                    </h:commandButton>
                </h:form>
            </ui:fragment>
        </h:panelGroup>

        <h:panelGroup id="thirdStep">
            <ui:fragment rendered="#{stateBean.thirdStep}">
                <span>CCCC</span>
                <h:form id="thirdStepForm">
                    <h:commandButton value="Finish">
                        <f:ajax event="action" render="-allContent" listener="#{stateBean.ajaxShowFinish}"></f:ajax>
                    </h:commandButton>
                </h:form>
            </ui:fragment>
        </h:panelGroup>

        <h:panelGroup id="finish">
            <ui:fragment rendered="#{stateBean.finish}">
                <span>FINISH!!!</span>

            </ui:fragment>
        </h:panelGroup>
    </h:panelGroup>
</aside>

そして、ここに豆があります:

@ManagedBean(name = "stateBean")
@ViewScoped
@Getter
@Setter
public class StateSavingBean implements Serializable{

private static final long serialVersionUID = 5264945113749405548L;

private Boolean firstStep;
private Boolean secondStep;
private Boolean thirdStep;
private Boolean finish;

public StateSavingBean() {

}

public void ajaxShowFirstStep(AjaxBehaviorEvent event) {
    setFirstStep(true);
    setSecondStep(false);
    setThirdStep(false);
    setFinish(false);
}

public void ajaxShowSecondStep(AjaxBehaviorEvent event) {
    setFirstStep(false);
    setSecondStep(true);
    setThirdStep(false);
    setFinish(false);
}

public void ajaxShowThirdStep(AjaxBehaviorEvent event) {
    setFirstStep(false);
    setSecondStep(false);
    setThirdStep(true);
    setFinish(false);
}

public void ajaxShowFinish(AjaxBehaviorEvent event) {
    setFirstStep(false);
    setSecondStep(false);
    setThirdStep(false);
    setFinish(true);
}

}

f:ajax の render 属性から "-allContent" を削除すると、Finish までのすべてのステップを渡すことができますが、前後のステップは非表示になりません。

解決策を見つけるのを手伝ってください。

私は使用しています:

サーバー: JBoss アプリケーション サーバー 7.1、

JSF: javax.faces-2.2.0-20130214.084242-247.jar

顔の構成:

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                        http://java.sun.com/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">
</faces-config>

ウェブモジュール: 3.0

いくつかの答え:

  1. 区切り文字が web.xml で変更されました:

    <context-param>
        <param-name>javax.faces.SEPARATOR_CHAR</param-name>
        <param-value>-</param-value>
    </context-param>
    
  2. h:panelGroup id="allContent" なしで試してみましたが、非表示にしたい表示された panelGroup と次に表示したい panelGroup のみをレンダリングしていました。結果は同じでした。

  3. MyFaces 2.1.10、Mojarra 2.0.3-FCS も使用しようとしましたが、結果は同じでした。BalusC は、JSF 2.2 で修正されたバグである可能性があると書いていますが、私はまだこの問題を抱えています。

誰かが私を助けてくれることを願っています。ありがとう!

4

0 に答える 0