Hey Charles,

Thanks for the input ... what I ended up doing is creating 2 actions-mapping
for one LookupDispatchAction.  One mapping validates and the other doesn't.
So my logic remians intect within one LookupDispatchAction class, while I
can enter the flow with/without validation.  Makes sense?  My concern is
that I will now have 2 instances of one action.  Is that true?

Darren.

-----Original Message-----
From: Charles McClain [mailto:[EMAIL PROTECTED]]
Sent: September 27, 2002 6:31 PM
To: 'Struts Users Mailing List'
Subject: RE: ValidatorForm


Darren:

Bear in mind that I'm relatively new to Struts and don't have all the
answers, nevertheless, I'll try to point you in the right direction.  I
had exactly the same problem, with the exception that I used a simple
DispatchAction rather than a LookupDispatchAction.

I found  Struts Tip #5 on Jguru, written by Ted Husted and titled, "Use
coarse-grained ActionForms ", which emphasized the distinction between
<form-bean>s and ActionForms -- and by extension, ValidatorForms.

The essence of it was that you can create multiple <form-bean>s in your
struts-config.xml which refer to the same ValidatorForm, and that your
validation.xml <form name="xxx"> goes by the <form-bean> name.

Thus, by creating one <form-bean> for your "view" and/or "create", and
another for your "update", and by creating corresponding <form
name="xxx"> entries in validation.xml (each with its own validation
rules), you can have different validations (including a null rule set,
meaning no validation) for the same ValidatorForm.

This does, however, cause you to make some decisions about your JSPs.
Unless you want to create separate JSPs to represent the two
ValidatorForms, you have to jump through some hoops to have your JSP
figure out which formBean its being passed to it (various tags require
the formBean name).  And if you want to vary the messages, button
captions, etc., on your JSP, you then have to use a bunch of logic:equal
tags to interrogate the formBean name.

Anyway, if you do decide to go this route, Chris Bartley sent me some
code which successfully retrieves the formBean name in your JSP.  Here
it is:

<bean:define id="actionMappingForThisScreen"
name="org.apache.struts.action.mapping.instance"
type="org.apache.struts.action.ActionMapping"/>
<bean:define id="formName" name="actionMappingForThisScreen"
property="name" type="java.lang.String" /> <bean:define id="formBean"
name="<%= formName %>" type="org.apache.struts.action.ActionForm"/>

Good luck, and if you figure out how to more easily re-use the same JSP
for all your actions, please post it.


-----Original Message-----
From: Darren Hill [mailto:[EMAIL PROTECTED]] 
Sent: Friday, September 27, 2002 10:42 Am
To: 'Struts Users Mailing List'
Subject: ValidatorForm

ur
Question.

I have a ValidatorForm form that works with a LookupDispatchAction.

One of the the actions is 'view'.  But this populates the form after
validation.  

The question is ... how can I selectively validate a ValiatorForm ( ie.
Don't validate for 'view', 'create', but validate for 'update', etc )

Darren

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



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

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

Reply via email to