After reading the initial newbie post, you then might come across a
situation where you need to have some things like "lists" on the page
that aren't related to your ActionForm. For example, in the User example
just given, imagine you need the person using the form to select a
"Department" that the user belongs in. You thus need a way to make sure
that a List of department is available on the page for the user to
select from.
Now before we get a ton of responses about how "here's why I came up
with this for Struts, and here's my solution...", I understand that many
of the ideas that many of you have come up with our very ingenious and
very practical once you understand the framework. I believe, however,
for someone new to Struts that it's better to Keep Things Simple and
keep things fairly consistent with what they are used to. For this
reason I suggest you do things this way....
In your DispatchAction simply provide a prep( HtttpServletRequest
request) method.
In there you simply do any preparation of things your form might need.
*NOTE* *NOTE* NOTE*: This is NOT, NOT, NOT where you do things like
populate the form with user information etc. This is only where you
would do things like provide lists for drop down so they are in scope.
The next more advanced question is "well what happens if you are using
validation and validation fails, how are these going to be in scope?"
I believe the answer is quite simple... just call validate from your
Action class versus relying on Struts to call it based on your struts
config setting!
I have more on this here
http://www.reumann.net/struts/articles/request_lists.jsp
The benefit to the prep() and the calling validate manually is
everything is quite simple... you are using a standard DispatchAction
which is easy for people to understand PLUS everything is all in one
place. When dealing with editing Users you can look in your
UserDispatchAction and see what's going on. No need to look at a bunch
of xml config settings, AspectJ inserts, or some other hidden stuff.
Granted yes, the newer frameworks handle all of this more gracefully,
but the problem is not "that big of a deal" with Struts. I've written
some pretty complex applications and the above has been working fine and
it becomes so simple to do.
--
Rick
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]