As an afterthought... I realized it may be useful to include my
struts-config file too.. So here it is
:)

-- Levi

----- Original Message -----
From: "Levi Cook" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 04, 2001 8:38 AM
Subject: Re: Multi-Page Forms


> Hi David,
>
> This isn't a complete solution (or explanation), but at a glance, I think
it
> may have some decent potential for mulitpage support.
>
> I followed your lead on declaritve validation, but took a slightly
different
> approach to its implementation.
>
> In a nutshell, creating a new form is completely unaware of its
validation.
> To create an "automatically" validated form, I just take the following two
> steps:
> 1. I place validation declarations in my Application.resources.
> 2. Then my forms extend ValidationFormAdapter, and I will automagically be
> validated.
>
> I've attached a zip file, which contains a preliminary round of the
relevant
> code. In particular, you're probably most interested in this hierarchy:
> ContactForm extends ValidatingFormAdapter extends ValidatingForm extends
> ActionForm <<struts>>
>
> As a peek, my declarations look like this:
> contactForm.required.fields=firstName,lastName,emailAddress
> contactForm.email.fields=emailAddress
> contactForm.date.fields=birthDate
>
> I believe that I can modify my ValidationForm+ValidationFormAdapter, to
> contain knowledge of what page, in a declared series I am working on.
>
> I'm interested in feedback from anyone, I also plan to announce a more
> complete version of this app. in the near future.
> Regards,
> Levi Cook
>
>
> ----- Original Message -----
> From: "David Winterfeldt" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, April 02, 2001 2:31 PM
> Subject: Multi-Page Forms
>
>
> > I know this has been discussed before, but I was in a
> > group and we were discussing if there was any way to
> > completely separate the view from the controller for
> > multi-page forms.  I've did a multi page example where
> > you specified what page you were on in a hidden field
> > and also associated a field with a page so the
> > validation would know what to validate.
> >
> > The best idea that came out of the group was to define
> > a separate action in the struts-config.xml that would
> > share the same Action and ActionForm class and have a
> > previous and next forward defined to navigate through
> > the multiple pages.  Validation would be performed by
> > checking the request object and using reflection to
> > only check the fields that were submitted.  This way
> > the page designer could just layout the pages and
> > define the actions and it keeps the view separate from
> > the controller.  As far as knowing when you were at
> > the end to run all validations again, I thought that
> > if there was no 'next' forward defined the controller
> > could look for a 'success' forward.
> >
> > The only other issue left which is a pain is how to
> > deal with resetting default checkbox values (possibly
> > pass in the defaults along with the action so it isn't
> > hard coded?).
> >
> > Any thoughts, comments, or different ways of handling
> > this would be appreciated.
> >
> > David
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get email at your own domain with Yahoo! Mail.
> > http://personal.mail.yahoo.com/?.refer=text
>
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">

<struts-config>
    <data-sources>
      <data-source 
          autoCommit="true"
          driverClass="org.gjt.mm.mysql.Driver"
          maxCount="4"
          minCount="2"          
          url="jdbc:mysql://localhost/pab"
          user="dba"
          password="sql"/>
  </data-sources>
  
  <!-- ========== Form Bean Definitions =================================== -->
  <form-beans>
  
    <form-bean   name="contactForm"
                 type="com.papajo.examples.pab.struts.ContactForm"/>
                 
    <form-bean   name="contactSearchForm"
                 type="com.papajo.examples.pab.struts.ContactSearchForm"/>
                
  </form-beans>

  <!-- ========== Action Mapping Definitions ============================== -->
  <action-mappings>
    <action      path="/contactList"
                     type="com.papajo.examples.pab.struts.ContactListAction"
                     name="contactSearchForm"
                     scope="request"
                     validate="false">
          <forward name="success" path="/WEB-INF/jsp/contactList.jsp"/>
    </action>
    
    <action      path="/editContact"
                 type="com.papajo.examples.pab.struts.ReadContactAction"
                 name="contactForm"
                 scope="request"
                 validate="false">
          <forward name="success" path="/WEB-INF/jsp/editContact.jsp"/>
    </action>
    
    <action      path="/viewContact"
                 type="com.papajo.examples.pab.struts.ReadContactAction"
                 name="contactForm"
                 scope="request"
                 validate="false">
              <forward name="success" path="/WEB-INF/jsp/viewContact.jsp"/>
    </action>

    <action      path="/deleteContact"
                 type="com.papajo.examples.pab.struts.DeleteContactAction">
      <forward name="success" path="/contactList.do" redirect="true"/>
    </action>
    
    <action      path="/saveContact"
                 type="com.papajo.examples.pab.struts.SaveContactAction"
                 name="contactForm"
                 scope="request"
                 validate="true"
                 input="/WEB-INF/jsp/editContact.jsp">
      <forward name="success" path="/contactList.do" redirect="true"/>
    </action>       
  </action-mappings>

</struts-config>

Reply via email to