javajavabeansstruts-1struts-actionactionform

Struts 1.x ActionForm Action Class


I've got a simple html page with four buttons. I know how to map the buttons so that the Action Class gets the value of whatever is selected and call a method based on each button in the Action Class. However, what should I do with the Action Form? Can I just leave it blank? It seems that struts requires you to map a bean, yet I'm not really sure what to put in the Action Form, since all that I'm trying to do is call methods in the Action Class.


Solution

  • The struts is what we call nowadays as "action-based" framework. Nowadays most frameworks are what we call "event-based" framework.

    It was built to make your life easier when you need to fill huge html forms and then send it to the server.

    It was not intended to make your life easier when pressing a button to execute some code on the server and then return with that specific small result.

    The main idea of struts was that, big things and change the entire view.

    This example (and mabye those ones, takes forever to download) how easier struts made the form-processing easier. see "5. Action (Controller)" of first link.

    If not clear, in the time, when there were just servlets, you needed something like this to parse a form.

    TL;DR; In the end the ActionForm is there just to help you with your html forms that otherwise you would need to parse by hand instead to receive them as well-formed java beans.