代码之家  ›  专栏  ›  技术社区  ›  SomeFatMan

重置jsp页时出现问题

  •  0
  • SomeFatMan  · 技术社区  · 16 年前

    我正在使用richfaces处理jsp页面。我的当前页面有多个feild和一个add和一个reset按钮。

    add按钮调用一个方法来验证用户输入的值。验证完成后,将向页面底部的列表中添加一个新条目,并调用重置按钮使用的重置方法重置页面,以便可以输入另一个条目。除了在一种情况下,所有的工作都正常,在验证输入的信息时,我想从用户那里确认一些东西。我向用户展示了一个带有确认选项和取消选项的modalpanel。

    这是我开始有问题的地方。我的confirm按钮调用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" />&nbsp;&nbsp;
        <r:componentControl for="confirmUnchangedExpected" attachTo="confirm" operation="hide" event="onclick"/>
    

    背豆:

    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 "";
    }
    
    1 回复  |  直到 16 年前
        1
  •  0
  •   SomeFatMan    16 年前

    所以我通过设置 rerender

    推荐文章