Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Interest »

Re: Properties file or a Constants Class

mail.laconiadatasystems.com

2005-01-13

Replies:

Ted Husted explains this at
http://www.jguru.com/faq/view.jsp?EID=995474

This example straight from Ted Husted
This form

<html:hidden property="dispatch" value="error"/>
function set(target){document.forms[0].dispatch.value=target;}
<html:submit onclick="set('save');">SAVE</html:submit>
<html:submit onclick="set('create');">SAVE AS NEW</html:submitl>
<html:submit onclick="set('delete);">DELETE</html:submit>

sets the hidden Dispatch Property
which selects mapped 'ActionForward' to relay to the appropriate RelayAction

to quote Ted
"The Struts framework already provides ActionForwards to describe how
control flows through the application. An action mapping can have any number
of local forwards. So it follows that we should be able to use local
forwards to dispatch control. Each of the local forwards can represent one
of the form operations. So, for example, the "copy" forward can send control
to the copy action, and the "delete"forward can send control to the delete
action. "

using a struts-config.xml which illustrates the above control flow..

<action name="articleForm" path="/do/article/Submit" ... >
  <forward name="create" path="/do/article/Create"/>
  <forward name="save" path="/do/article/Store"/>
  <forward name="delete" path="/do/article/Recycle"/>
  <forward name="cancel" path="/do/Menu"/>
</action>

//Since RelayAction is configured thru action-mapping it can be coded to
return the
// 'correct RelayAction' in this manner
public final class RelayAction extends Action {
  public ActionForward perform(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException {

    return mapping.findForward(request.getParameter(Tokens.DISPATCH));

  }
} // end RelayAction

//It looks up the Dispatch parameter in the request and uses the value of
that parameter to
//select the proper method. In the case of delete RelayAction will look up
the
// "delete" forward and return it to the controller (the controller will
//forward to /do/article/Recycle causing the Recycle action to execute

I like this solution because it uses architecture to route control to the
right object and thus limits scoping of variables to ONLY those identified
within the execution chain

Sorry for the digression--
Martin-


----- Original Message -----
From: "Darryl Pierce" <mcpierce@(protected)>
To: <J2EE-INTEREST@(protected)>
Sent: Thursday, January 13, 2005 9:18 AM
Subject: Re: Properties file or a Constants Class


> On Thu, 13 Jan 2005 08:53:35 -0500, LDS
> <webmaster@(protected):
> > Personally I prefer Struts RelayAction or ParameterAction to handle
these
> > scenarios but I dont want to start a religious war
>
> Can you give me an explanation of why you think either a RelayAction
> or a ParameterAction is appropriate for handling constants or
> persistent storage of variables? I'm sorry, but I don't understand
> your message within the context of this thread.
>
> --
> Darryl L. Pierce <mcpierce@(protected)>
> Visit the Infobahn Offramp: <http://mcpierce.mypage.org>
> "By doubting we come to inquiry, through inquiry truth." - Peter Abelard
>
>
===========================================================================
> To unsubscribe, send email to listserv@(protected)
body
> of the message "signoff J2EE-INTEREST". For general help, send email to
> listserv@(protected)".

===========================================================================
To unsubscribe, send email to listserv@(protected)
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@(protected)".
©2008 junlu.com - Jax Systems, LLC, U.S.A.