我正在使用richfaces在jsp頁面上工作。我目前的頁面有多個字段和一個添加和重置按鈕。重置jsp頁面的問題
重置按鈕可以正常工作,在我的supportbean中調用一個方法,使頁面上相應的字段爲null並重置其他一些分類值。問題是我的添加按鈕。
add按鈕調用驗證用戶輸入的值的方法。驗證完成後,會將新條目添加到頁面底部的列表中,並調用重置按鈕使用的重置方法來重置頁面,以便可以輸入其他條目。除了在一種情況下一切正常,同時驗證輸入的信息我想確認用戶的一些信息。我向用戶顯示帶有確認選項和取消選項的模式面板。
這裏是我開始有問題的地方。我的確認按鈕在我的supportbean中調用一個方法,它設置了一些值,然後回想一下我的add方法。我知道這不是優雅,但我不能提出更好的解決方案。現在,當add方法完成執行重置方法時被調用,並且我的頁面上沒有任何事情發生。如果我點擊我的重置按鈕,頁面重置並且條目被添加到列表中。
我不明白爲什麼頁面在所有情況下重置,除非我展示模態面板。任何幫助表示讚賞。
代碼的一些部分組成:
JSP頁:
<h:commandButton value="Add" style="font-size:10pt;font-weight:bold" action="#controller.add}" binding="#{controller.addButton}"/>
<h:commandButton value="Reset" action="#{controller.reset}" style="font-size:10pt;font-weight:bold"/>
模式面板(jsp頁面的一部分)
<a:commandButton id="confirm" action="#{controller.proceed}" styleClass="confirmIconButton" value="Yes, proceed" />
<r:componentControl for="confirmUnchangedExpected" attachTo="confirm" operation="hide" event="onclick"/>
支持bean:
public String add() {
...
if (somethinghappend) getPanel().setRendered(true);
...
list.add(entry);
reset();
return "";
}
public String reset() {
// resets the feilds on the page
return "";
}
public String proceed() {
//change values so something does not happen
add();
return "";
}