Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
class MyAction extends ActionSupport {
   private boolean submit;
   private boolean clear;
   public void setSubmit(boolean submit) {
      this.submit = submit;
   }
   public void setClear(boolean clear) {
      this.clear = clear;
   }
   public String execute() {
      if (submit) {
         doSubmit();
         return "submitResult";
      }
      if (clear) {
         doClear();
         return "clearResult";
      }
      return super.execute();
   }
}

...

Explanation

The boolean properties 'submit' and 'clear' will be set to 'true' or 'false' according weather the submit or clear form element is present in the submitted form.

...

Code Block
class MyAction extends ActionSupport {
   private String buttonName;
   public void setButtonName(String buttonName) {
      this.buttonName = buttonName;
   }
   public String execute() {
      if ("Submit".equals(buttonName)) {
         doSubmit();
         return "submitResult";
      }
      if ("Clear".equals(buttonName)) {
         doClear();
         return "clearResult";
      }
      return super.execute();
   }
}

Explaination

In this case, the properties are String, therefore the values set are also String in nature.

...