Hi all!

The more I did into Struts the more I like it.  I have noticed
something that has me scratching my head a bit, wondered
if anybody else had come up with a clean solution.

Struts has a nice clean approach to organizing code and
behaviour after you click on something.  In other words, if
I have a form then I have a nice way in Struts to associate
the handler with the form.  If I have a URL then there are
decent ways that I can maintain the destinations in the
controller instead of in the html/jsp pages.  All nice.

What I don't see is a straight-forward way of indicating
what I want *before* going to a JSP page.

Ok, I know... that probably sounds a little odd.  My point
is simply this: my JSP pages are maintainable because
they, as view artifacts, don't know much about each other.
If I want may action classes to be just as maintainable
then they can't know much about each other either.

That is the thing I don't like about actions at the moment.
The action figures out how to process the incoming data
from the request *and* prepare the page/session/whatever
context before going to the next page.  An action can only
do that if it *knows* what the next page will require.  That
 means there is less point in having that transition information
explicitly captured in struts-config.xml because I might have
to know the same information implicitly in the action code.

So, here is what I want, and I'm hoping somebody has
already found a clean approach for it.  Instead of only
writing "process-X" actions, I also want to write some 
"prepare-for-Y" actions.  Then any JSP page has
potentially two actions; one executed as I head
into the page (e.g. to prep dynamic content), the other
executed as I head out of the page (e.g. for user response).
The clean way I can think of is to have some kind of
action that iterates over the beans that will be needed
by the next page, i.e.:

- step 1, if I don't have a UserBean, get me a UserBean
- step 2, if I don't have a UserPrefsBean, get me one
  (etc)

Then, you'd need some way of getting a controller-mediated
way of recognizing that some particular action must be
invoked to get a UserBean, etc., and then returning control
back to the "prep" action.  Once the prep action has
everything it needs, it forwards to the next step.

Is this crazy?  Sane but not done before?  Sane and
done already?  

Inquiring minds want to know!

Thanks.... Reid

 

 



---------------------------------
Do You Yahoo!?
Send your FREE holiday greetings online at Yahoo! Greetings.

Reply via email to