You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Reumann <r...@reumann.net> on 2003/03/15 00:01:29 UTC

[Q] Scaffolding question in relation to multiple possible forwards

Maybe this question is best asked on Ted's book site, but I figured I'd
ask here first since it's not totally related to his book.

I'm looking at Ted's Artimus example application and I really like the
whole scaffolding approach. Really cool.

The question I have though is it seems basically he uses the one
ProcessAction which takes a ProcessBean and, assuming no Exceptions are
thrown, it will forward to the success declaration in the ActionMapping.

What I'm wondering about is what if you want to handle different
forwards based on different possible outcomes after your
ProcessResultBase returns in your ProcessBean? It looks like you could
provide a "dispatch" parameter in your ProcessResult class to change the
direction of the forward but, since the ProcessResult is not really a
Struts component I don't really want to declare that type of behavior
there.

I'm not really sure of the best way to handle this. It might help with
an example...

Imagine an online review form. Normally after submitting the review
(which enters the review into the database) you forward the user to some
X page. However, maybe you want to send people who are age 70 to a
different page so they can answer some survey questions.


It would seem to make sense to set this action up like:

<action
        path="/submitReview"
        type="org.apache.struts.scaffold.ProcessAction"
        parameter="foo.bar.SaveReview"
        name="reviewForm"
        scope="request"
        validate="true">
       <forward
            name="success"
            path="standardPage.jsp"/>
	<forward
            name="age70"
            path="survey.jsp"/>
</action>

Using the scaffolding approach how would I tell my application I need to
forward them to the surveyPage if they are age 70? I certainly don't
want to hard code this anywhere in the SaveReview since I want that
object to be reusable and not dependent at all on Struts. 

I take it I would need to create a special subclass of ProcessAction to
handle this? (ie ReviewAction extends ProcessAction ) or is there
something already in place that I'm missing with the scaffolding
framework?

Thanks for any help.

-- 
Rick Reumann

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