Ah, so it does submit both submit buttons as ajax request params.
I think I liked it better when the g:form action was the only
determining factor in which Grails action is called :) If you have
two submit buttons that you want to perform different actions, can't
you just delegate from the your grails action based on the params? It
seems like Grails is _completely_ ignoring the request URL (or at
least the action) altogether in this case.
If you follow the HTTP/HTML paradigm, a form can only submit to _one_
action URL. So in my mind Grails would be better off following that
standard, with a URL mapping to a Grails action (as is still the case
most of the time). I think if you add form parameters as part of the
action determination, it becomes much more difficult to
programmatically call a given action because you need to then give the
correct URL _and_ magical _action_ parameter. I don't like this idea;
it makes me think of JSF and ASP.NET which can barely even perform an
action request without all sorts of convoluted request parameters and
javascript.
I suppose it's a little late for me to complain since the feature is
already implemented, but I don't think I like the idea of the Grails
action being dependent on parameters.
-Tom
Post by Brad WhitakerThe issue in GRAILS-3109 is related but not really the same. The current
issue is strictly an AJAX issue. If, for instance, you have a non-AJAX form
<g:form method="post" >
<g:actionSubmit value="Foo #1" action="fooOne" />
<g:actionSubmit value="Foo #2" action="fooTwo" />
</g:form>
<form action="/test103/test/failed" method="post" >
<input type="submit" name="_action_fooOne" value="Foo #1" />
<input type="submit" name="_action_fooTwo" value="Foo #2" />
</form>
If you click the button in the browser then the params will contain ONLY the
submit that you clicked -- the other 'submit' will not be included in the
params.
If you add AJAX to the form then you run into problems. Suppose you change
<g:form method="post" >
<g:submitToRemote update="updateMe"/>
<g:actionSubmit value="Foo #1" action="fooOne" />
<g:actionSubmit value="Foo #2" action="fooTwo" />
</g:form>
<form action="/test103/test/failed" method="post" >
<input onclick="new
Ajax.Updater('updateMe','/test103/test/failed',{asynchronous:true,evalScripts:true,parameters:Form.serialize(this.form)});return
false" type="button"></input>
<input type="submit" name="_action_fooOne" value="Foo #1" />
<input type="submit" name="_action_fooTwo" value="Foo #2" />
</form>
The problem is that if you click the "Ajax" button then the values of the
two submit buttons, e.g. _action_fooOne and _action_fooTwo are unfortunately
included in the params of the request. Grails chooses an action based upon
the first _action_* param that it finds in the request and ignores the
action associated with the updateMe button that was clicked.
Post by Brock HeinzHey Guys,
http://www.nabble.com/formRemote--%3E-404----grails-system-update.dispatch-td17810585.html#a17810585
http://jira.codehaus.org/browse/GRAILS-3109
Brock
Post by Brad WhitakerI encountered essentially the same problem today on my project. We're not
using submitToRemote but we are doing an ajax submission of a form that
contains <g:actionSubmit>. The problem is that the javascript is submitting
all "inputs" in the request, even the <g:actionSubmit action="foo">, which
results in the following HTML: <input type="submit" name="_action_foo"
....>. Grails sees "_action_foo" in the request parameters and says "aha! we
need to execute action=foo" even though the user didn't click the button
associated with action foo.
I'm not what can be done to fix this. <g:actionSubmit> may simply be
incompatible with forms that are submitted with ajax. Perhaps there is a way
to modify the client side JavaScript so that inputs with type=submit are
omitted from the request parameters? If the client side script can be
modified in this way then I think the problem would be solved.
Brad
Post by Ivan StaskovHi,
I have tried to migrate my application to Grails-1.0.3 and found problem
using g:submitToRemote and g:actionSubmit tags into the same form.
<g:form name="testForm" method="post">
<div id="updateArea">
${message}
</div>
<g:submitToRemote action="submitToRemote"
update="[success:'updateArea']" value='SubmitToRemote'/>
<g:actionSubmit action="actionSubmit" value='ActionSubmit'/>
</g:form>
This code was working properly under Grails-1.0.2 and there were
possibility to submit form as to 'submitToRemote' action (via remote
ajax), so and to 'actionSubmit' action. But under Grails-1.0.3 it's not
working. When you press 'SubmitToRemote' button, on server side will be
called 'actionSubmit' action and return wrong result.
I have attached small test application
http://www.nabble.com/file/p18318628/test.zip test.zip where you can
reproduce this problem.
Any ideas? As i already said, till Graills-1.0.3 this functionality worked
properly...
Thank you.
--
http://www.nabble.com/Problem-using-g%3AsubmitToRemote-and-g%3AactionSubmit-together.-tp18318628p18375210.html
Sent from the grails - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
--
View this message in context: http://www.nabble.com/Problem-using-g%3AsubmitToRemote-and-g%3AactionSubmit-together.-tp18318628p18386409.html
Sent from the grails - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email