java struts1: forward from action to action with One ActionForm

4.5k Views Asked by At

Like I said in the title , I have two actions ( studentAction , UpdateStudentAction ) One , action form : studentForm and the struts-config like :

<action path="/student"
    type="action.StudentAction"
    name="studentForm"
    scope="request"
    validate="true"
    input="tiles.etudiant"
    parameter="dispatch">       
    <forward name="UpdateStudent"  path="/updateStudent.do" redirect="true" />  
</action>

<action path="/updateStudent"
    type="action.UpdateStudentAction"
    scope="request"
    name="studentForm"
    input="tiles.modifierEtudiant"
    parameter="dispatch">
</action>

First action method to redirect

public ActionForward onModifier(
        ActionMapping mapping,
        ActionForm form,
        javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response)
        throws DatabaseFailureException {       
StudentForm studentForm=(StudentForm)form;
return mapping.findForward("UpdateStudent");

}

The Second Action method (recipient) :

public ActionForward onInitialiser(
        ActionMapping mapping,
        ActionForm form,
        javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response)
        throws DatabaseFailureException {

        StudentForm studentForm=(StudentForm)form;
        //etudiantForm.setIdEtudiantSelectionne("1");
        List listeCriteres=new ArrayList();
        listeCriteres.add(new SearchBean(new Etudiant().HQL_ID_ETUDIANT(), etudiantForm.getIdEtudiantSelectionne()));   etudiantForm.setListeEtudiants(getReferenceDataService().findListBoParCriteres(Etudiant.class, listeCriteres));

        return mapping.getInputForward();   }

**Here is the probleme , the second action get an empty form from the first one ** how can i fix this problem ?!

1

There are 1 best solutions below

0
On BEST ANSWER

yes one more way is changing the redirect attribute value to false <forward name="UpdateStudent" path="/updateStudent.do" redirect="false" />