输入字段在提交和重定向后不能清空? [英] Input fields not emptying after submit and redirect?

查看:112
本文介绍了输入字段在提交和重定向后不能清空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想从我的jsf页面删除飞机时,如果飞机成功删除,并且我做了一个重定向到页面并显示警告,告诉用户飞机已被成功删除。但是,用户在h:inputText中输入的值仍然存在,它们不会为空。

When I want to "delete a plane" from my jsf page, if successful the plane deletes, and I do a redirect to the page and show an alert telling the user the plane was succesfully deleted. However, the values the user entered in the h:inputText are still there, they dont empty.

JSF Page:

<h:form>
    <h:panelGrid columns="3" class="table">
        <h:outputLabel value="Plane ID" />
        <h:inputText  value="#{listAirplaneBB.airPlaneId}"/>
        <h:commandButton value="Delete" 
            class="btn btn-primary"
            action="#{addAirplaneCtrl.deleteAirplane}" />
    </h:panelGrid>
</h:form>

Bean代码

Bean code:

public String deleteAirplane(){
    //delete the plane
    return private/user?faces-redirect=true;
}

关于为什么字段在重定向后不会空的任何想法?

Any ideas on why the fields dont empty after redirect?

推荐答案

也许你的listAirplaneBB是一个@ViewScoped bean(不能告诉你的例子)。

在这种情况下,你必须在重定向之前手动清理任何特定字段,因为JSF在目标页面未更改时保持活动状态。

Maybe your listAirplaneBB is a @ViewScoped bean (cant tell by your example).
In that case you have to clean any particular fields manually before redirecting as JSF keeps alive that bean while the target page has not changed.

这篇关于输入字段在提交和重定向后不能清空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆