views:

101

answers:

1

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

+2  A: 

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...
Kdeveloper
Brilliant, the worked a treat.I did manage a work around using flash scope and a redirect, but this must be the correct way to handle it.
Davoink
I only use redirect after post requests, because it stops accidental double form submissions in case the browser back button is used. I all cases other cases the BeanFirstPopulationStrategy does its work.
Kdeveloper