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!");
}