I don't like relying on Javascript. Sometimes in fact I can't. But I see
what you mean. Also the action saves whatever changes are done to the
data on the screen, and then I use that strategy to pass on the request
to the other mapping.
On 10/30/2004 04:20 PM David G. Friedman wrote:
> Adam,
>
> Why don't you use Javascript? You could have each submit button change the
> this.form.action (where the URL saying where to POST/GET the form to is
> located) to make the page directly submit from the browser to the exact
> Action once. This would remove the need for you to map between actions
> (redirect="false" or not) to forward to another action, as your code sample
> suggests (or to use a DispatchAction).
>
> Regards,
> David
>
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
> Sent: Saturday, October 30, 2004 8:43 AM
> To: Struts Users Mailing List
> Subject: specifying action forwards
>
>
> I just finished a project and once again Struts provided an excellent,
> elegant framework for the presentation tier. However I'm not happy with
> one thing.
>
> The page design which I was not allowed to change was very complex. Each
> page had up to a dozen submit buttons.
>
> So what I did was this: I named each submit button and had a large
> if-else-if-else-if in my Action to test for the presence of each button
> name in the request params:
>
>
> save(stuff)
> if (request.getParameter(Constants.SUBMIT_GO_HERE))
> mapForward = Constants.SUBMIT_GO_HERE
> else if (request.getParameter(Constants.SUBMIT_GO_THERE))
> mapForward = Constants.SUBMIT_GO_THERE
> else if (request.getParameter(Constants.SUBMIT_GO_SOMEWHERE_ELSE))
> mapForward = Constants.SUBMIT_GO_SOMEWHERE_ELSE
> else
> throw new Exception("messed up again!")
> return mapForward
>
> The problem with this is that these button names all need a
> corresponding forward in the struts-config mapping, and I kept messing
> up and always got it wrong about five times before I was done on any
> page, and so did the rest of the team.
>
> In the JSP it is easy enough to specify the button name using expression
> language, but this mechanism is always vulnerable to mistakes in the
> struts-config.xml. And refactoring was a nightmare!
>
> Is it realistic to think of adapting struts to take the class & static
> declaration in the struts-config.xml? Like this:
>
> <action path="/asdfasdf">
> <forward name="Constants.SUBMIT_GO_HERE" path=".thisTile"/>
> <forward name="Constants.SUBMIT_GO_THERE" path=".thatTile"/>
> <forward name="Constants.SUBMIT_GO_SOMEWHERE_ELSE"
> path="/somewhere.do" redirect="true"/>
> </action>
>
>
> The intention is to throw an ugly exception at start-up.
>
> Am I dreaming? Or have I missed a better solution somewhere?
>
>
> Thanks for any opinions
> Adam
> --
> struts 1.2 + tomcat 5.0.19 + java 1.4.2
> Linux 2.4.20 Debian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
struts 1.2 + tomcat 5.0.19 + java 1.4.2
Linux 2.4.20 Debian
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
|