【发布时间】:2010-06-28 22:07:19
【问题描述】:
我正在使用richfaces 处理jsp 页面。我当前的页面有多个字段以及一个添加和一个重置按钮。
重置按钮工作正常,在我的 backingbean 中调用一个方法,该方法使页面上的相应字段为空并重置一些其他分类值。问题在于我的添加按钮。
添加按钮调用验证用户输入值的方法。验证完成后,将在页面底部的列表中添加一个新条目,并调用重置按钮使用的重置方法来重置页面,以便可以输入另一个条目。一切正常,除了在一种情况下,在验证输入的信息时我想从用户那里确认一些事情。我向用户展示了一个带有确认选项和取消选项的模态面板。
这是我开始遇到问题的地方。我的确认按钮调用了我的 backingbean 中的一个方法,该方法设置了一些值,然后调用了我的 add 方法。我知道这并不优雅,但我想不出更好的解决方案。现在,当 add 方法完成执行 reset 方法时,我的页面上什么也没有发生。如果我单击我的重置按钮,页面将重置并且一个条目将添加到列表中。
我不明白为什么页面在所有情况下都会重置,除非我显示模式面板。任何帮助表示赞赏。
部分代码:
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 "";
}
【问题讨论】: