Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 529
enkor Avatar asked Jun 08 '10 15:06

enkor


1 Answers

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...
like image 111
Kdeveloper Avatar answered Sep 20 '22 01:09

Kdeveloper