Carlton Carlton - 4 months ago 42
HTML Question

Input fields not emptying after submit and redirect?

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: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}" />

Bean code:

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

Any ideas on why the fields dont empty after redirect?


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.