tags:

views:

182

answers:

3

I have created a new action called "updateWithHistory" on a controller "X" similar to update. When I use this code from a scaffolded edit.gsp page:

<span class="button"><g:actionSubmit class="save" action="updateWithHistory" value="${message(code: 'default.button.updateWithHistory.label', default: 'Persist')}" /></span>

I get a 404 error:

The requested resource (/GPECAN/WEB-INF/grails-app/views/X/updateWithHistory.jsp) is not available.

I don't know why Grails is looking for the view and not for the action. I don't need a view for that action because it redirects to existing actions (list, edit, etc.).

This does not happen with the default scaffolded actions like "update". Any ideas?

(Of course, if I create a view called "updateWithHistory.gsp", the view is shown, but the action is never executed...I'm desperate)

+1  A: 

There are two ways to solve your problem, depending what you want to achieve. First thing that you have to know is quote from documentation:

Also note that this tag relies on the multipart resolver to be able to inspect parameters included with mulitpart requests. If you disable the resolver by setting grails.disableCommonsMultipart to true in Config.groovy, actionSubmit will not work.

So two solutions:

  1. Set 'controller' attribute in g:form tag
  2. Create URL mapping as described here

P.S. If you want to see any 'renderable' result by browser you have to use controller's dynamic render method :)

Olexandr
+1  A: 

You have probably bug in your controller. After your action you need to render something or redirect. Take a good look on scaffolded controller code.

Try to add following on the end of your updateWithHistory action.

render(view: "edit", model: [yourDomainInstance: yourDomainInstance])
amra
A: 

OK, I'm just stupid. It was an uncatched error in my controller; the error situation was ocurring but there was not specific view to handle it, so the controller tried to redirect to an unexisting default view.

Sorry a lot for my stupidity and thanks for your help

Miguel