You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lukas Österreicher <lu...@inode.at> on 2004/02/03 10:35:09 UTC

Problem handling error forwards

Hello

For some time now I have had a problem when dealing with errors and the resulting different forwards:

When action3 generates an error (for instance in the form validator) and forwards
to action2 to deal with it (display it) but this action2 deals with errors and forwards
to action1 then the jsp for action1 is displayed, but not the jsp for action2.

(Those three actions are a process sequence, action1 prepares a page
to enter some data, action2 (and form2) check that data and allow entering
additional data and send it to action3 where the data is saved.)

Why is this?

Here the actions for details:

    <!-- specify the directory from which to imort sound files -->
    <action   path="/specifysounddirectory"
              type="net.morkeleb.yarf.action.SpecifySoundDirectoryAction"
              name="addTracksForm"
              scope="request"
              validate="false"
              input=".specifysounddir">
      <forward name="success"              path=".specifysounddir"/>
      <forward name="failure"              path=".specifysounddir"/>
    </action>

    <!-- display which files are available in the selected directory
          and allow to select which to import -->    
    <action   path="/listaddtracks"
              type="net.morkeleb.yarf.action.ListAddTracksAction"
              name="addTracksForm"
              scope="request"
              validate="true"
              input=".specifysounddir">
      <forward name="success"              path=".listaddtracks"/>
      <forward name="failure"              path=".specifysounddir"/>
    </action>

    <!-- import selected files -->
    <action   path="/addtracks"
              type="net.morkeleb.yarf.action.AddTracksAction"
              name="addTracksForm"
              scope="request"
              validate="true"
              input="/listaddtracks.do">
      <forward name="success"              path="/listtracks.do"/>
      <forward name="failure"              path="/listaddtracks.do"/>
    </action>
  </action-mappings>

As you see action3 (addtracks) forwards to /listaddtracks.do
(it has to be the action because data the avaiable tracks
have to be prepared for display). If it would forward to the
.listaddtracks tile the error would be correctly displayed
in action2 but the avaiable tracks would not be prepared.

As addtracks forwards to listaddtracks with an error
(only when it occours ofcourse) listaddtracks somehow
recognizes that existing error and thinks: we have an
error, so I have to forward to .specifysounddir to
display it.

Can you help me on this?

Regards,
Lukas Österreicher



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Problem handling error forwards

Posted by Lukas Österreicher <lu...@inode.at>.
Am 03.02.2004 10:48:10, schrieb Dirk Markert <di...@dr-markert.de>:

>It's not the action recognizing the error but your addtrackForm.
>Validate is called on forwarding to your action2.

Ah, right. I was half aware of this but now that I thought of this
I found a solution:

at the end of each form validation I have:

if(!errors.isEmpty()) {
	logger.debug("There has been an error, setting errors to true");
	request.setAttribute("errors", "true");
}

As the equest.setAttribute("errors", "true"); command makes struts
forward to the input page I changed the form to only
validate if no errors were set. This seemed to fix it.

Thanx!

Lukas

>Hello Lukas,
>
>
>***************************************************************
>
>LÖ> Hello
>
>LÖ> For some time now I have had a problem when dealing with
>LÖ> errors and the resulting different forwards:
>
>LÖ> When action3 generates an error (for instance in the form validator) and forwards
>LÖ> to action2 to deal with it (display it) but this action2 deals with errors and forwards
>LÖ> to action1 then the jsp for action1 is displayed, but not the jsp for action2.
>
>LÖ> (Those three actions are a process sequence, action1 prepares a page
>LÖ> to enter some data, action2 (and form2) check that data and allow entering
>LÖ> additional data and send it to action3 where the data is saved.)
>
>LÖ> Why is this?
>
>LÖ> Here the actions for details:
>
>LÖ>     <!-- specify the directory from which to imort sound files -->
>LÖ>     <action   path="/specifysounddirectory"
>LÖ>              
>LÖ> type="net.morkeleb.yarf.action.SpecifySoundDirectoryAction"
>LÖ>               name="addTracksForm"
>LÖ>               scope="request"
>LÖ>               validate="false"
>LÖ>               input=".specifysounddir">
>LÖ>       <forward name="success"              path=".specifysounddir"/>
>LÖ>       <forward name="failure"              path=".specifysounddir"/>
>LÖ>     </action>
>
>LÖ>     <!-- display which files are available in the selected directory
>LÖ>           and allow to select which to import -->    
>LÖ>     <action   path="/listaddtracks"
>LÖ>               type="net.morkeleb.yarf.action.ListAddTracksAction"
>LÖ>               name="addTracksForm"
>LÖ>               scope="request"
>LÖ>               validate="true"
>LÖ>               input=".specifysounddir">
>LÖ>       <forward name="success"              path=".listaddtracks"/>
>LÖ>       <forward name="failure"              path=".specifysounddir"/>
>LÖ>     </action>
>
>LÖ>     <!-- import selected files -->
>LÖ>     <action   path="/addtracks"
>LÖ>               type="net.morkeleb.yarf.action.AddTracksAction"
>LÖ>               name="addTracksForm"
>LÖ>               scope="request"
>LÖ>               validate="true"
>LÖ>               input="/listaddtracks.do">
>LÖ>       <forward name="success"              path="/listtracks.do"/>
>LÖ>       <forward name="failure"              path="/listaddtracks.do"/>
>LÖ>     </action>
>LÖ>   </action-mappings>
>
>LÖ> As you see action3 (addtracks) forwards to /listaddtracks.do
>LÖ> (it has to be the action because data the avaiable tracks
>LÖ> have to be prepared for display). If it would forward to the
>LÖ> .listaddtracks tile the error would be correctly displayed
>LÖ> in action2 but the avaiable tracks would not be prepared.
>
>LÖ> As addtracks forwards to listaddtracks with an error
>LÖ> (only when it occours ofcourse) listaddtracks somehow
>LÖ> recognizes that existing error and thinks: we have an
>It's not the action recognizing the error but your addtrackForm.
>Validate is called on forwarding to your action2.
>LÖ> error, so I have to forward to .specifysounddir to
>LÖ> display it.
>
>LÖ> Can you help me on this?
>
>LÖ> Regards,
>LÖ> Lukas Österreicher
>
>
>
>LÖ> ---------------------------------------------------------------------
>LÖ> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>LÖ> For additional commands, e-mail:
>LÖ> struts-user-help@jakarta.apache.org
>
>
>
>Regards,
>Dirk
>
>+------- Quality leads ---------------------------------------+
>| Dirk Markert                     dirk.markert@dr-markert.de |
>| Dr. Markert Softwaretechnik AG                              |
>| Joseph-von-Fraunhofer-Str. 20                               |
>| 44227 Dortmund                                              |
>+---------------------------------->>>>>>> to success! <<<<<<-+ 
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Problem handling error forwards

Posted by Dirk Markert <di...@dr-markert.de>.
Hello Lukas,


***************************************************************

LÖ> Hello

LÖ> For some time now I have had a problem when dealing with
LÖ> errors and the resulting different forwards:

LÖ> When action3 generates an error (for instance in the form validator) and forwards
LÖ> to action2 to deal with it (display it) but this action2 deals with errors and forwards
LÖ> to action1 then the jsp for action1 is displayed, but not the jsp for action2.

LÖ> (Those three actions are a process sequence, action1 prepares a page
LÖ> to enter some data, action2 (and form2) check that data and allow entering
LÖ> additional data and send it to action3 where the data is saved.)

LÖ> Why is this?

LÖ> Here the actions for details:

LÖ>     <!-- specify the directory from which to imort sound files -->
LÖ>     <action   path="/specifysounddirectory"
LÖ>              
LÖ> type="net.morkeleb.yarf.action.SpecifySoundDirectoryAction"
LÖ>               name="addTracksForm"
LÖ>               scope="request"
LÖ>               validate="false"
LÖ>               input=".specifysounddir">
LÖ>       <forward name="success"              path=".specifysounddir"/>
LÖ>       <forward name="failure"              path=".specifysounddir"/>
LÖ>     </action>

LÖ>     <!-- display which files are available in the selected directory
LÖ>           and allow to select which to import -->    
LÖ>     <action   path="/listaddtracks"
LÖ>               type="net.morkeleb.yarf.action.ListAddTracksAction"
LÖ>               name="addTracksForm"
LÖ>               scope="request"
LÖ>               validate="true"
LÖ>               input=".specifysounddir">
LÖ>       <forward name="success"              path=".listaddtracks"/>
LÖ>       <forward name="failure"              path=".specifysounddir"/>
LÖ>     </action>

LÖ>     <!-- import selected files -->
LÖ>     <action   path="/addtracks"
LÖ>               type="net.morkeleb.yarf.action.AddTracksAction"
LÖ>               name="addTracksForm"
LÖ>               scope="request"
LÖ>               validate="true"
LÖ>               input="/listaddtracks.do">
LÖ>       <forward name="success"              path="/listtracks.do"/>
LÖ>       <forward name="failure"              path="/listaddtracks.do"/>
LÖ>     </action>
LÖ>   </action-mappings>

LÖ> As you see action3 (addtracks) forwards to /listaddtracks.do
LÖ> (it has to be the action because data the avaiable tracks
LÖ> have to be prepared for display). If it would forward to the
LÖ> .listaddtracks tile the error would be correctly displayed
LÖ> in action2 but the avaiable tracks would not be prepared.

LÖ> As addtracks forwards to listaddtracks with an error
LÖ> (only when it occours ofcourse) listaddtracks somehow
LÖ> recognizes that existing error and thinks: we have an
It's not the action recognizing the error but your addtrackForm.
Validate is called on forwarding to your action2.
LÖ> error, so I have to forward to .specifysounddir to
LÖ> display it.

LÖ> Can you help me on this?

LÖ> Regards,
LÖ> Lukas Österreicher



LÖ> ---------------------------------------------------------------------
LÖ> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
LÖ> For additional commands, e-mail:
LÖ> struts-user-help@jakarta.apache.org



Regards,
Dirk

+------- Quality leads ---------------------------------------+
| Dirk Markert                     dirk.markert@dr-markert.de |
| Dr. Markert Softwaretechnik AG                              |
| Joseph-von-Fraunhofer-Str. 20                               |
| 44227 Dortmund                                              |
+---------------------------------->>>>>>> to success! <<<<<<-+ 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org