I get that if I have a html form then I should use an ActionForm to read user input in my Action.
But should I consider all kind of user input as form data?
Lets say I have an link with query parameters passed to my Action? Should I still make use of an ActionForm? For example showProfile.do?userid=XXXXX. What is the recommended way to read this kind of user input? Should I use request.getParameter("userid") for this kind of input? Is it a good idea to use an ActionForm but have another naming pattern for these ActionForm classes, like UserActionQuery?
I'm a new developer in Struts 1.2 and I know I could do as I want. But I'm kind of looking for a good practice pattern.
The standard way of fetching parameters in action classes is using an ActionForm
.
But if you want you can access parameters both ways you described in your question, using Form getters/setters or using request.getParameter("userId")
.
FormAction is to get the values of the form elements. So if you want to pass a parameter in the URL , you should use the other way.