我正在使用Eclipse Luna EE,Tomcat v7.0和ICEFaces 3.2如何從ICEfaces模式彈出窗口調用託管bean?
我有一個用於輸入信息的標籤打印表單,例如項目號,項目名稱和標籤類型。用戶然後提交表單。這將信息發送到ZPL字符串中的標籤打印機,然後打印出該物品的正確標籤。這一切都沒有問題。
如果價值很高(100+生產),表格會對打印數量進行檢查。如果打印數量超過某個值(純粹出於測試目的),那麼「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!");
}
我想我已經想出了一個修復。現在正在測試它。我已經刪除了模式彈出窗口,並向qty輸入字段中引入了「valueChangeListener」。然後我添加了一個面板確認,如果數量高於設定值,則會顯示該確認。 – Thraydor