Hi,
I am trying to implement a wizard form in Struts 2, using the SCOPE INTERCEPTOR.

That wizard is used to register a new user.
I have 3 pages :
In the first page, the user chooses a login and a password.
In the second page, the user enters his phone number, age, first name, name, 
fax.
In the third page, the user enters his adress details : country, street name, 
street number, post code.

There is one final action that is launched when the user clicks on SUBMIT in 
the third page.
This action should get all the information entered in the 3 pages and insert it 
into the database.

So far is what i have got :

First page : login.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>

<link href="<s:url value="/css/styles.css"/>" rel="stylesheet" type="text/css"/>
<s:head theme="xhtml"   /> 
<s:debug/>
<center>

 <s:form action="nouvLogin" method="POST" theme="xhtml"   >
    <tr>
        <td colspan="2"> Choisissez un login et un password</td>
    </tr>
    
     <tr>
       <td colspan="2">
             <s:actionerror />
            <!-- <s:fielderror /> --> 
       </td>
    </tr>

    <s:textfield name="login" key="nouvLogin.login" />
    <s:password name="password" key="nouvLogin.pwd"/>
    <s:submit value="Valider" align="center"/>
</s:form>
<br/>

</center>

Second page : nouvUtilisateur.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>

<link href="<s:url value="/css/styles.css"/>" rel="stylesheet" type="text/css"/>
<s:head theme="xhtml"   /> 
<s:debug/>
<center>

<s:form action="confirmDetails" method="POST" theme="xhtml"   >
   <table>
     <tr>
       <td colspan="2">
             <s:actionerror />
            <!-- <s:fielderror /> --> 
       </td>
    </tr>
    <tr>
        <s:textfield name="nom"  value="nom" />
        <s:textfield name="prenom"  value="prenom" />
        <s:textfield name="telephone"  value="telephone" />
        <s:textfield name="titre"  value="titre" />
        <s:textfield name="fax"  value="fax" />
        <s:submit value="Valider" align="center"/>
    </tr>
    </table>

</s:form>
<br/>

</center>

third page : nouvAdresse.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>

<link href="<s:url value="/css/styles.css"/>" rel="stylesheet" type="text/css"/>
<s:head theme="xhtml"   /> 
<s:debug/>
<center>

<s:form action="confirmAdresse" method="POST" theme="xhtml"   >
   <table>
     <tr>
       <td colspan="2">
             <s:actionerror />
            <!-- <s:fielderror /> --> 
       </td>
    </tr>
    <tr>
        <s:textfield name="codepostal"  value="codepostal" />
        <s:textfield name="departement"  value="departement" />
        <s:textfield name="numero"  value="numero" />
        <s:textfield name="pays"  value="pays" />
        <s:textfield name="rue"  value="rue" />
        <s:textfield name="ville"  value="ville" />
        <s:submit value="Valider" align="center"/>
    </tr>
    </table>
    
</s:form>
<br/>

</center>

Here is what i got in struts.xml :

<action name="nouvLogin" >  
        <interceptor-ref name="defaultStack"/>  
        <interceptor-ref name="scope">  
            <param name="session">login, password</param>  
            <param name="type">start</param>  
            <!-- Do i need the key parameter ? What should i put in there ? -->
            <param name="key">goods:</param> 
        </interceptor-ref>  
        <result name="success" type="tiles">VenteEnLigne.utilisateur</result> 
    </action>

    <action name="confirmDetails"> 
        <interceptor-ref name="defaultStack"/> 
        <interceptor-ref name="scope"> 
            <param name="session">nom, prenom, telephone, titre, fax</param> 
            <!-- Do i need the key parameter ? What should i put in there ? -->
            <param name="key">goods:</param>
        </interceptor-ref> 
        <result name="success" type="tiles">VenteEnLigne.adresse</result> 
    </action>

    <action name="confirmAdresse" class="UtilisateurAction"  
method="creerNouvelUtilisateur"> 
        <interceptor-ref name="defaultStack"/> 
        <interceptor-ref name="scope"> 
            <param name="session">codepostal, departement, numero, pays, rue, 
ville</param> 
            <param name="type">end</param> 
            <!-- Do i need the key parameter ? What should i put in there ? All 
previous key parameters ? -->
            <param name="key">goods:</param>
        </interceptor-ref> 
        <result name="success" 
type="tiles">VenteEnLigne.inscriptionFin</result> 
    </action> 
    

As i commented out inside struts.xml, i am a bit lost with what i should put 
inside the interceptor-ref tag.
There is little documentation and samples about its use.

Also, what exactly are the advantages of the SCOPE interceptor ?

Thanks for helping.



      

Reply via email to