I'm a fairly new Struts user, struggling to get up
that first hump on the learning curve, so sorry if
this is a clueless question:

I have a family of subclasses descended from a common
base class. Because they are all similar, I wrote one
DisplayAction to look up and display any of the
subclasses. Each subclass has its own JSP for display
and the DisplayAction is able to select an appropriate
ActionForward based on which subclass we are
displaying. So far, so good.

Likewise I want like to write a single EditAction to
display any of the subclasses in an appropriate form,
and a single UpdateAction to handle saving changes
back to my model when the form is submitted. Each of
the subclasses has its own ActionForm and
corresponding JSP for editing.

Part of the goal here is to make it as easy as
possible to add another subclass. I specifically
*don't* want to have to write all the CRUD actions
separately for each individual subclass.

My dilemma is this: How do I choose dynamically (at
run-time) which ActionForm is to be submitted to my
UpdateAction? I don't know which Form I'll need until
I know what subclass I am updating, so configuring it
statically in an <action> element in struts-config.xml
won't work.

Do I need to have a separate <action> element for
updating each subclass? That sounds tedious,
especially if they all call the same Action and differ
only in their "name" attribute. Should I make one
giant ActionForm that has all the fields of all the
subclasses? That seems messy. Is there a cleaner way
by subclassing one of the struts components?

It seems that using the "name" and "type" attributes
of the <html:form> tag might work, because that would
allow the JSP to specify what type of ActionForm it
needs, which is what I want. But, these attributes are
deprecated. Why are they deprecated?

Anyway, it's my experience that when you're fighting
the framework, you're probably doing something wrong.
But, it seems like this would be a common situation.
So, is there a simple solution? Am I totally on crack
for wanting to do it this way? Thanks for any hints
and suggestions!!

-chris



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to