looks like you are looking at the framework from an angle where-in
everything seems to be wrong for you.

We are happy users of Struts and it really helps in our development life
cycle. May be you should try to get the example application working and
check whether the validation works. Please note the validation can be
called from either ActionForm validation or ActionClass perform methods.

Biju Isac





                                                                                       
                               
                    Bryan                                                              
                               
                    Field-Elliot           To:     [EMAIL PROTECTED]      
                               
                    <bryan_lists@ne        cc:                                         
                               
                    tmeme.org>             Subject:     Presenting an "edit form" - 
example is WAY way bad...         
                                                                                       
                               
                    04/05/01 10:40                                                     
                               
                    AM                                                                 
                               
                    Please respond                                                     
                               
                    to struts-user                                                     
                               
                                                                                       
                               
                                                                                       
                               



Good grief, I've spent half the evening trying to understand the "proper
way" in Struts to present the user with a pre-populated editable form
(using ActionForm, a JSP page, and an Action). And, I am not even
certain I have it figured out quite yet.

My first point, is that the struts-example of editing a form (the
RegistrationForm and the EditRegistrationAction classes) is pretty bad,
or should I say, hard to follow.

This is how I THINK I have the example figured out, and I'd appreciate
it if someone could correct me where I'm wrong --

1. The process is initiated via a hyperlink in mainMenu.jsp, directly to
the EditRegistrationAction action, and without any form submission.
2. EditRegistrationAction's ActionMapping (in struts-config.xml) is
configured to use the RegistrationForm as it's ActionForm, but with
VALIDATE=FALSE.
3. EditRegistrationAction notices that the process() parameter "form" is
null, and therefore creates a form, populates it, and saves in the
request scope, and then forwards to the JSP page "registration.jsp".
4. registration.jsp displays the populated form, which is eventually
re-submitted back to EditRegistrationAction and saved to disk.

Is this right? Now, I believe I have spotted a hole in this design --
that is, since the ActionMapping for EditRegistrationAction has
"validate=false" in it, then the validate() method for the
RegistrationForm is never called. This means that, while validation
occured at user signup time, it is not validating their edits. This
seems wrong to me. But how to rectify it? I know why you have set
validate=false, it's to let the ActionForm through without errors on the
first pass (since all it's fields are blank). Should we be manually
calling form.validate() from within the action class, in this instance?

Confused, tired, and with aching head,

Bryan





Reply via email to