You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sa...@Punemail.ltitl.com on 2001/06/12 09:32:28 UTC

Handling Multipart forms (sort of Wizard)



Hello All,

I am using mulipart forms for adding an employee information.
In this I have 3 forms namely, emplEducation, emplExperience, emplGeneral in
separate JSPs.
In this case, I am using only one form bean for all these JSPs and only one
action class.

My problem is how to validate the Form bean after each page submission:
------------------------------------------------------------------------------------------------------------

I know the validation can be done in the form bean using validate() method or in
the action class

But, if user filled emplEducation form and press "Next", to go to
emplExperience,
how do I validate only those form bean fields related to emplEducation and not
the others till they are entered by user??
Is there any straight forward strategy for handling this??

- Sandeep











Re: Handling Multipart forms (sort of Wizard)

Posted by Ted Husted <hu...@apache.org>.
I haven't tried this yet, but one way might be to setup an ActionMapping 
for each step in the Wizard, and set the parameter property for each. 

Struts passes the ActionMapping to validation, so you should be able 
to use mapping.getParameter() to tell where you are. 

You can then use this same technique within an Action, if you need to
perform any processing between steps (like routing to a different step 
based on what they selected). 

        <action-mappings>
		<!-- Entry point -->
            <action 
		parameter="step0"
                path="/wizard/Start"
                type="package.wizard"
                name="wizardForm"
                scope="session"
                validate="false">
                <forward 
                    name="success"  
                    path="/WEB-INF/jsp/wizard/Step1.jsp"/>
            </action>

        <action-mappings>
		<!-- Step1 submits here -->
            <action 
		parameter="step1"
                path="/wizard/Step1"
                type="package.wizard"
                name="wizardForm"
                scope="session"
                validate="true"
                input="/WEB-INF/jsp/wizard/Step1.jsp">
                <forward 
                    name="success"  
                    path="WEB-INF/jsp/wizard/Step2.jsp"/>
            </action>

        <action-mappings>
		<!-- Step2 submits here -->
            <action 
  		parameter="step2"
                path="/wizard/Step2"
                type="package.wizard"
                name="wizardForm"
                scope="session"
                validate="true"
                input="/WEB-INF/jsp/wizard/Step2.jsp">
		<!-- the package.wizard Action would check 
		the form and choose one of these forwards -->
                <forward 
                    name="rent"  
                    path="/wizard/Step3/rent.do"/>
                <forward 
                    name="own"  
                    path="/wizard/Step3/own.do"/>
            </action>

in validate()

String step = mapping.getParameter(); 

// ... handle validation for each step

in Action

String step = mapping.getParameter(); 

// .. analyze form, if needed, and route to next step



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/


Sandeep.Yawale@Punemail.ltitl.com wrote:
> 
> Hello All,
> 
> I am using mulipart forms for adding an employee information.
> In this I have 3 forms namely, emplEducation, emplExperience, emplGeneral in
> separate JSPs.
> In this case, I am using only one form bean for all these JSPs and only one
> action class.
> 
> My problem is how to validate the Form bean after each page submission:
> ------------------------------------------------------------------------------------------------------------
> 
> I know the validation can be done in the form bean using validate() method or in
> the action class
> 
> But, if user filled emplEducation form and press "Next", to go to
> emplExperience,
> how do I validate only those form bean fields related to emplEducation and not
> the others till they are entered by user??
> Is there any straight forward strategy for handling this??
> 
> - Sandeep

Handling nested properties

Posted by Victor Chai <ch...@yahoo.com.sg>.
Hi,

I have been working on struts a few days ago, I have
been trying to develop ordering system using struts.

I already have four Java Bean to represent an Order,
which contains OrderHeader and OrderDetail, and within
OrderDetail there will be collection of
OrderLineDetail, pls refer to below for detail,


public class Order implements Serializable {
  private OrderHeader=null;
  private OrderDetail=null;
  //other attributes and methods
}

public class OrderHeader implements Serializable {

//attributes and methods
}

public class OrderDetail implments Serializable {
  private OrderLineDetail[] orderlines=new
Hashtable();
  //other attributes and methods
}

public class OrderLineDetail implements Serializable {
  //methods and attributes

}

Based on the above design, how will it fit into struts
framework? 

I have been trying to use <logic:iterate>, seems that
it won't work.

Hope some expert can throw some light on me.

thanks!



__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send dad a Father's Day Card!
http://greetings.yahoo.com.sg/

RE: Handling Multipart forms (sort of Wizard)

Posted by Darryl Pentz <da...@vardus.co.za>.
Well I don't know if this is conventional, but what I've done is to add an
attribute to the form, say 'action', and to add action as a hidden field in
the form. Then assign it a different value on each form... in your case
maybe 'education', 'experience' and 'general'.

	<form:hidden property="action" value="education"/>

Then in your validate() method check what the action field is set to and
only validate the fields on that form.

Simple.

- Darryl

-----Original Message-----
From: Sandeep.Yawale@Punemail.ltitl.com
[mailto:Sandeep.Yawale@Punemail.ltitl.com]
Sent: 12 June 2001 09:32
To: struts-user@jakarta.apache.org
Subject: Handling Multipart forms (sort of Wizard)





Hello All,

I am using mulipart forms for adding an employee information.
In this I have 3 forms namely, emplEducation, emplExperience, emplGeneral in
separate JSPs.
In this case, I am using only one form bean for all these JSPs and only one
action class.

My problem is how to validate the Form bean after each page submission:
----------------------------------------------------------------------------
--------------------------------

I know the validation can be done in the form bean using validate() method
or in
the action class

But, if user filled emplEducation form and press "Next", to go to
emplExperience,
how do I validate only those form bean fields related to emplEducation and
not
the others till they are entered by user??
Is there any straight forward strategy for handling this??

- Sandeep