I've been wondering about the best way to go about using struts in this
situation....
I have two types of forms (for different kind of web registrations) which
are very similar, but not quite identical. The associated
RegistrationAction will perform slightly different tasks depending on which
form it is given. So I could go for two actions, one for each of the
forms. That'll work.
But I was wondering if instead I could do have a base RegistrationForm
(containing lots of common stuff), and then extend it to give me say
UserRegistrationForm and StaffRegistrationForm. A single action would
accept a form of type "RegistrationForm" and do whatever it needed to
do. (For the sake of argument, assume that the JSP form can be shared, so
validation is OK).
So I tried this, by having a startRegistrationAction that created an
instance of either StaffRegistrationForm or UserRegistrationForm , casting
it to be of type RegistrationForm, and put it in session scope under the
name "registrationForm" before forwarding on to the JSP form for the end
user to complete.
When the form is submitted to the RegistrationAction I get a null form
passed. The config I have is....
<form-bean
name="registrationForm"
type="RegistrationForm" />
<!-- Register a new user -->
<action
path="/register"
name="registrationForm"
type="RegistrationAction"
unknown="false"
input="/register.jsp"
validate="true">
</action>
The form tag looks like:
<html:form action="/register" scope="session" >
....and of course if I change the form-bean type to be
"StaffRegistrationForm" or "UserRegistrationForm" it will work for one of
those specific instances.
Am I right in thinking that because my form is of type (say)
StaffRegistraionForm (which happens to extend RegistrationForm), struts
won't be able to find a RegistrationForm type object in the session? Which
is why my Action sees a null form.
So my questions are really....
(1) is this a sane thing to be trying?
(2) is there a way to do this?
Many thanks
Richard
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>