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/


[EMAIL PROTECTED] 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

Reply via email to