How to clear a bean field with Stripes
In a JSP I have the following field:
<stripes:text 开发者_开发百科name="email"/>
This field is in my action bean(snippet):
public class CreateClaim implements ActionBean {
private String email;
public void setEmail(String email) {
this.email = email;
}
public String getEmail() {
return email;
}
public Resolution alc(){
email = "poodle";
return new ForwardResolution("aForward.jsp");
}
}
In the alc() methos I am setting email to be null. But when the pages renders the value of the email field is exactly as it was entered originally. Is there a way of clearing this field once and event has triggered?
Cheers
Dave
This has to do with the population strategy of the Stripes framework. By default it has a Request first strategy (due to backward compatibility with earlier versions), but I always change it to the bean first population strategy.
Just edit the web.xml to add a init-param for your Stripes filter:
<filter>
<filter-name>StripesFilter</filter-name>
<filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
<init-param>
<param-name>PopulationStrategy.Class</param-name>
<param-value>
net.sourceforge.stripes.tag.BeanFirstPopulationStrategy
</param-value>
</init-param>
..etc...
精彩评论