1

Eclipse Luna EE、Tomcat v7.0、ICEFaces 3.2 を使用しています。

ユーザーがアイテム番号、アイテム名、ラベルタイプなどの情報を入力するラベル印刷用のフォームがあります。次に、ユーザーはフォームを送信します。これにより、情報が ZPL 文字列でラベル プリンターに送信され、アイテムの正しいラベルが印刷されます。これはすべて問題なく動作します。

フォームは、高い値 (生産では 100 以上) の場合、印刷数量に対してチェックを行います。印刷枚数が特定の値 (> 2。純粋にテスト目的) を超える場合、"testFlag" ブール値が true に設定され、モーダル ボックスが表示され、印刷コマンドが実行されないようにエラー フラグが設定されます。

モーダル ボックスでは、ユーザーが正しい数量を入力したかどうかを確認し、[はい]/[いいえ] ボタンを使用できます。

printUI とモーダル ポップアップは同じ<ice:form>要素内にあり、testFlag が true に設定されている場合、ポップアップ ボックスがレンダリングされて表示されます。

問題: モーダル ボックスの [はい] ボタンをクリックしても、割り当てたアクションが実行されません ( System.out.println("Yes Button!"))。モーダル ボックスが閉じ、何も起こりません。

フォームを再送信すると、モーダル ボックスが再び表示され、[はい] をクリックしても何も起こりません。

数量を 2 に変更して送信すると、問題なく印刷コマンドが実行されます。

セッションの処理方法に問題があると推測しています。

質問: モーダル ボックスの [はい] ボタンをクリックして、必要なコードを実行するにはどうすればよいですか?

私が試した:<ice:commandLink><h:button><h:commandButton>を 使用して<h:commandLink>

モーダル ポップアップとフォームを別々の<ice:form>タグに配置します (これにより、セッションが更新され、入力されたすべてのデータが削除されます)。

を使用してactionListener

フォームを含むコード:

<h:body>
    <div id="surround">
        <ice:form id="test" prependId="false">
            <ui:include src="./printUI.xhtml" />
            <ui:include src="./printQtyPopup.xhtml" />
        </ice:form>
    </div>
</h:body>

printQtyPopup.xhtml

    <ui:composition>
        <ice:panelPopup modal="true" visible="#{validateBean.testFlag}" rendered="#{validateBean.testFlag}">
            <f:facet name="header">
                <ice:outputText value="Print Quantity Check" />
            </f:facet>
            <f:facet name="body">
                <ice:panelGrid>
                    <ice:outputText value="You selected a print quantity of: #{validateBean.printAmount}" />
                    <ice:outputText value="Is this correct?" />
                    <ice:panelGroup>
                        <ice:commandButton value="No" />
                        <ice:commandButton value="Yes" action="#{validateBean.checkQtyYes}" />
                    </ice:panelGroup>
                </ice:panelGrid>
            </f:facet>
        </ice:panelPopup>
    </ui:composition>

関連する ValidateBean.java コード

    public void validate() { //validation checks are carried out when the user clicks "Print" on the printUI.
        if (!errorFlag && checkQty && printQty > 2) {
            testFlag = true;
            errorFlag = true;
            System.out.println("Qty Check Modal");
        }

        if (!errorFlag) {
            if (printQty > 0) {
                initialiseString();

                initialisePrinter();

                clear();
            } else {
                printQty = 0;
                errorMessage = true;
                quantityInvalid = true;
                errorFlag = true;
            }
        }
    }

    public void checkQtyYes() {
        System.out.println("Yes Button!");
    }
4

1 に答える 1

0

代替案を見つけました。

モーダルポップアップとそれにリンクされているコードを削除しました。

<ice:panelConfirmation>フォームの最後に a を追加しました。これは、印刷枚数が設定した数値を上回っている場合にのみレンダリングされます。

valueChangeListener="#{validateBean.printQtyChange}"Print Quantity<h:inputText>でa を使用して番号を取得しますonblur="submit()"

を試しましたonchange="submit()"が、一連の印刷ジョブを送信するときに問題が発生しました。属性を強制的にアクティブにするには、「ENTER」を押す必要がありonchangeますが、これはユーザーが望んでいないと確信しています。


<ice:panelConfirmation>、フォームの送信を一時停止することで機能し、送信を続行または停止する前に応答を待ちます。これは、モーダルポップアップで達成しようとしていたことを達成します。


印刷枚数入力テキスト:

<h:inputText id="printQty" value="#{validateBean.printAmount}" size="8" autocomplete="off" 
    maxlength="3" required="true" onblur="submit()" 
    valueChangeListener="#{validateBean.printQtyChange}" />

値変更リスナー:

public void printQtyChange(ValueChangeEvent e) {
    printAmount = e.getNewValue().toString();

    try {
        ls.setPrintQty(Integer.parseInt(printAmount));
    } catch (NumberFormatException eve) {
        errorMessage = true;
        quantityInvalid = true;
        errorFlag = true;
    }

    printQty = ls.getPrintQty();

    System.out.println("Qty : " +printQty);

    if (printQty < 1) {
        errorMessage = true;
        quantityInvalid = true;
        errorFlag = true;
    }
}

パネル確認:<ice:form>。フォーム締め切り直前

<ice:panelConfirmation id="confirmQty"
    acceptLabel="Yes"
    cancelLabel="No"
    message="Your entered the quantity: #{validateBean.printQty}. Is this correct?"
    title="Confirm Quantity"
    draggable="false"
    rendered="#{validateBean.printQty > 2}" />

印刷ボタン:<ice:panelConfirmation>

<ice:commandButton styleClass="button" id="printButton" value="Print" 
    actionListener="#{validateBean.validate}" panelConfirmation="confirmQty" />

誰かが条件付きの ICEfaces モーダル ポップアップからマネージド Bean を呼び出す方法を知っていれば、それも素晴らしいでしょう。


更新 以来、すべて<h:inputText>を変更し、数量の入力フィールドにを<ice:inputText>追加しました。partialsubmit="true"これを追加すると、削除できましたonblur="submit()"

新しい印刷枚数入力テキスト:

<ice:inputText id="printQty" value="#{validateBean.printAmount}" size="8" autocomplete="off"
    maxlength="3" required="true" valueChangeListener="#{validateBean.printQtyChange}"
    partialSubmit="true" />

これにより、一連のジョブを送信するときに問題が発生することがあった問題が解消されました。

不要なコードが実行されるのを防ぐために、他のすべての入力フィールドを宣言する必要があっpartialsubmit="true"たため、 を付けていません。確認したい入力欄だけにしておいた方がすっきりします。<ice:form>partialsubmit="false"

于 2016-01-26T10:19:30.647 に答える