You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Derek Lin <de...@hotmail.com> on 2002/10/28 03:57:17 UTC

Problem with multiple html(jsp) pages sharing one form (actionform)

I find this paragraph from the "programming struts" book:
"You don't have to declare an ActionForm for every HTML form in your application.  The same ActionForm can be associated with one or more action mappings. This means that they can be shared across multiple HTML forms. For example, if you had a wizard interface, where a set of data was entered and posted across multiple pages, a single ActionForm can be used to capture all of this data, a few fields at a time."

So I tried to implement similar pages.  
Here is the form:
        <form-bean
            name="RegistrationForm"
      dynamic="true"
            type="org.apache.struts.validator.DynaValidatorForm">
          <form-property name="userRole" type="java.lang.String"/>
          <form-property name="firstName" type="java.lang.String"/>
          <form-property name="lastName" type="java.lang.String"/>
          <form-property name="companyName" type="java.lang.String"/>
          <form-property name="companyAddressType" type="java.lang.String"/>
          <form-property name="companyStreet" type="java.lang.String"/>
          <form-property name="companyStreet2" type="java.lang.String"/>
          <form-property name="companyCity" type="java.lang.String"/>
          <form-property name="companyState" type="java.lang.String"/>
          <form-property name="companyProvince" type="java.lang.String"/>
          <form-property name="companyZip" type="java.lang.String"/>  
          <form-property name="companyCountry" type="java.lang.String"/>
          <form-property name="companyPhone" type="java.lang.String"/>
          <form-property name="companyPhoneType" type="java.lang.String"/>
          <form-property name="companyFax" type="java.lang.String"/>
          <form-property name="companyEmail" type="java.lang.String"/>
          <form-property name="companyEmailType" type="java.lang.String"/>
         <form-property name="companyPassword" type="java.lang.String"/>    
     <form-property name="companyPassword2" type="java.lang.String"/> 
          <form-property name="companyUsername" type="java.lang.String"/>
          <form-property name="creditcardType" type="java.lang.String"/>
          <form-property name="creditcardNumber" type="java.lang.String"/>
          <form-property name="creditcardExpDate" type="java.lang.String"/>
          <form-property name="userPhone" type="java.lang.String"/>
          <form-property name="userPhoneType" type="java.lang.String"/>
          <form-property name="userFax" type="java.lang.String"/>
          <form-property name="userEmail" type="java.lang.String"/>
          <form-property name="userEmailType" type="java.lang.String"/>
    </form-bean>

Here are my actions mapping:
        <action
          path="/registration-user"
          input="/registration/company.jsp"
          name="RegistrationForm"
          parameter="/registration/user.jsp"
          scope="session"
          type="org.apache.struts.actions.ForwardAction"
          validate="true"/>
        <action
          path="/registration-creditcard"
          input="/registration/user.jsp"
          name="RegistrationForm"
          parameter="/registration/creditcard.jsp"
          scope="session"
          type="org.apache.struts.actions.ForwardAction"
          validate="true"/>
        <action
            path="/registration-company-all"
            type="com.futurecargo.framework.actions.EJBRegistrationAction"
            name="RegistrationForm"
            scope="session"
            validate="true"
            input="/registration/creditcard.jsp">
     <forward name="success" path="/registration/success.jsp" />
     <forward name="failure" path="/index.jsp" />
    </action>

The problem is that the form values are not being carried over.  (I am thinking if I need to use hidden values on my subsequent html pages).  Has anyone successfully implemented something like this?  Please help.

Thanks,

Derek