Original solution

Introduction

Often, we have multiple submit buttons within a single form. The below is just a simple way of identifying which button was clicked, and which actions to take.

There are, of course, many ways of doing this, including the use of JavaScript to identify the actions, etc... You're welcome to pick and choose whichever method you find most useful. Struts 2 is flexible enough.

Explanation

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

I don't really like this method, as it ties in the Action to the Form. (What happens if you want different text to show up on the button ? You would have to change both the form as well as the corresponding action.)

Conclusion

There are other ways to achieve the same functionality. There are pros and cons to each methods. Feedback welcome.

For best practice, if you have common data loaded / managed by your actions (submit & clear), then for example, you can define a MyBaseAction class, extended by MySubmitAction and MyClearAction class. Then this is how they looks like: