You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kruse, Matt" <MK...@aquent.com> on 2003/04/09 04:40:50 UTC

"default" forward?

I'd like to bounce this idea off experienced struts users to see if it makes
any sense.

With most Actions, there is a "default" forward, ie, the JSP that goes with
the Action by default. For example, if the Action is ViewRecord, you want
the JSP that displays the record.

Is there anything bad about naming a forward "default" and putting a path to
it? My thinking is this:

1) In my project's ProjectBaseAction, return the "default" forward if my
sub-class doesn't return an action.
2) Many Actions will have a "default" action, but not all
3) Define a global forward named "default"
4) Any Actions which fail to return a forward automatically get set to
"default" which if it doesn't exist for the action will default to the
global forward, which will be an error page that just says "hey stupid, you
forgot to set a forward!"

I see a few minor benefits:
1) Each subclass doesn't need to explicitly return an ActionForward if it's
just using the default display JSP
2) Tracking down "null forwards" is an easy task, because an error page will
be shown

Does that make any sense? Feel free to shoot me down, I'm just trying to get
a list of "design recommendations" and "do's and dont's" in my head with
regards to how to best organize and design a struts-based project. If anyone
has written such a document already, please let me know so I can read it :)

Matt Kruse

Re: "default" forward?

Posted by Navjot Singh <na...@net4india.net>.
there is nothing bad in doing whatever you are thinking. all depends upon
your requirement.

But you can always specify 1 action as "unknown" per config file. if request
comes to action other than defined ones, it can handle that request.

by making that action paramterized, you can also forward the control to
whereever you want.

regards
navjot singh



----- Original Message -----
From: "Kruse, Matt" <MK...@aquent.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, April 09, 2003 8:10 AM
Subject: "default" forward?


| I'd like to bounce this idea off experienced struts users to see if it
makes
| any sense.
|
| With most Actions, there is a "default" forward, ie, the JSP that goes
with
| the Action by default. For example, if the Action is ViewRecord, you want
| the JSP that displays the record.
|
| Is there anything bad about naming a forward "default" and putting a path
to
| it? My thinking is this:
|
| 1) In my project's ProjectBaseAction, return the "default" forward if my
| sub-class doesn't return an action.
| 2) Many Actions will have a "default" action, but not all
| 3) Define a global forward named "default"
| 4) Any Actions which fail to return a forward automatically get set to
| "default" which if it doesn't exist for the action will default to the
| global forward, which will be an error page that just says "hey stupid,
you
| forgot to set a forward!"
|
| I see a few minor benefits:
| 1) Each subclass doesn't need to explicitly return an ActionForward if
it's
| just using the default display JSP
| 2) Tracking down "null forwards" is an easy task, because an error page
will
| be shown
|
| Does that make any sense? Feel free to shoot me down, I'm just trying to
get
| a list of "design recommendations" and "do's and dont's" in my head with
| regards to how to best organize and design a struts-based project. If
anyone
| has written such a document already, please let me know so I can read it
:)
|
| Matt Kruse
|


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