History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-3086
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Graeme Rocher
Reporter: Evan Slatis
Votes: 7
Watchers: 7
Operations

If you were logged in you would be able to see more operations.
Grails

form/actionSubmit tags broken (actionSubmit url overridden/ignored in browser location bar)

Created: 09/Jun/08 02:42 PM   Updated: 14/Jun/08 04:15 AM
Component/s: TagLib
Affects Version/s: 1.0.3
Fix Version/s: 1.0.4

Time Tracking:
Not Specified

Environment: JDK 1.6_03, Vista

Testcase included: yes


 Description  « Hide
The predicted behavior for the following code should be to print 'success' to the console and browser after pressing the submit button. This does work as expected, rendering 'success' in both places, but the url in the location bar reads "http://localhost:8080/test/test/failed".
class TestController {

    def defaultAction = 'failed'

    def failed = {
        println 'failed'
        render('failed')
    }

    def success = {
         println 'success'
         render('success')
     }
 
     def test = {}

}


Test.gsp:

    <g:form controller="test">
        <g:actionSubmit name="testButton" value="Submit" />
    </g:form>

Adding the success action to the form tag sets the url correctly in the browser's location bar. Also, entering the 'failed' url in location bar correctly works as expected. Tests with multiple actionSubmit tags with different actions will yield similar results (i.e. the original action will execute, but the location bar will be set to the forms expected url, overriding the actionSubmit's).

There was other behavior reported and observed where action's were unable to execute in this scenario, but I have been unable to replicate that at this time, and redirect's from the original action behave exactly as expected regardless. Therefore, I left the priority as 'major'.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Peter Ledbrook - 10/Jun/08 04:12 AM
I'm not sure what to do about this. Everything is working as expected, it is just that the 404 error is mis-leading. I have had a quick look at the code, and it seems that fixing the 404 error would be non-trivial.

Evan Slatis - 10/Jun/08 09:40 AM
Much apologies. I was playing around to check out different scenarios, and I posted the wrong view code. Use this instead:
    <g:form controller="test">
        <g:actionSubmit name="testButton" value="Success" action="success"/>
    </g:form>

I left off the action attribute, which otherwise wouldn't behave as I described without that. The code above in your view will produce the incorrect behavior above.


Peter Ledbrook - 13/Jun/08 10:59 AM
I keep thinking about this, but the only solution I can come up with is to simply not include the default action in the form's target URL. This would avoid the confusion caused when using the <g;actionSubmit> tag.

Evan Slatis - 13/Jun/08 11:14 AM
I agree. I have been trying to come up with something clever for days, but nothing comes to my mind, either. Definitely, the location bar shouldn't show the wrong URL, so this is perfectly acceptable.

Peter Ledbrook - 14/Jun/08 04:15 AM
When somebody fixes this, please update the Grails functional test FormsControllerTest.testActionSubmit() in the HelloWorld test app. There is a line commented out that tests for the behaviour described in my previous comment.