|
I am using Grails 2.0 and I have a link that is resulting two actions being executed (confirmed by stepping through with a debugger) and I have no idea why.
Here is the markup: <<a href="${createLink(controller: 'agent', 'edit', params: ['id': agent.id])}">${agent.login}</a></td> <td>${agent.displayName}</td><td><g:remoteLink action="getSkills" onSuccess="showSkillPopup(data)" params="['id': agent.id]">Show Agent's Skills</g:remoteLink></td> The resulting HTML: <a href="/ivacd-manager/agent/edit/1002077">0115 </a></td> <td>Redacted </td><td><a href="/ivacd-manager/agent/getSkills/1002077" onclick="jQuery.ajax({type:'POST',data:{'id': '1002077'}, url:'/ivacd-manager/agent/getSkills',success:function(data,textStatus){showSkillPopup(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});return false;" action="getSkills">Show Agent's Skills</a></td> The problem is when I click on the /agent/edit/1002077 link it executes the edit action but then also executes the getSkills action. Mappings: 10:35:02,664 [Thread."http-bio-8080"-exec-8] RegexUrlMapping DEBUG : Created reverse URL mapping [/agent/edit/1002077] for parameters [{id=1002077, controller=agent, action=edit}] 10:35:02,686 [Thread."http-bio-8080"-exec-8] RegexUrlMapping DEBUG : Created reverse URL mapping [/agent/getSkills/1002077] for parameters [{id=1002077, controller=agent, action=getSkills}] When I click the edit link: 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [500] 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [/] 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [/misc/(*)] 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [/dev/(*)/(*)] 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [/(*)/(*)?/(*)?] 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Matched URI [/agent/edit/1002077] with pattern [/(*)/(*)?/(*)?], adding to posibilities The actual actions in the controller: def getSkills() { def id = params.id def agentSkillDtos = agentService.getSkillsForAgent(id) render agentSkillDtos as JSON } def edit() { def debugger = params.id //Just so I can set a breakpoint here in the debugger render(view: 'edit') } What ends up happening if I click the edit link, is it executes the edit action,then executes the getSkills action. Then I get a page of JSON in the browser since that is the last render executed. Can anyone provide any insight? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Oh yeah, if I change the param to be anything else besides "id", like "agentId" then the resulting HTML is /ivacd-manager/agent/edit?agentId=1002077 and then everything works fine.
On Jan 4, 2012, at 10:48 AM, Parmeley, Michael wrote: > I am using Grails 2.0 and I have a link that is resulting two actions being executed (confirmed by stepping through with a debugger) and I have no idea why. > > Here is the markup: > > <<a href="${createLink(controller: 'agent', 'edit', params: ['id': agent.id])}">${agent.login}</a></td> <td>${agent.displayName}</td><td><g:remoteLink action="getSkills" > onSuccess="showSkillPopup(data)" > params="['id': agent.id]">Show Agent's Skills</g:remoteLink></td> > > The resulting HTML: > > > <a href="/ivacd-manager/agent/edit/1002077">0115 </a></td> <td>Redacted </td><td><a href="/ivacd-manager/agent/getSkills/1002077" onclick="jQuery.ajax({type:'POST',data:{'id': '1002077'}, url:'/ivacd-manager/agent/getSkills',success:function(data,textStatus){showSkillPopup(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});return false;" action="getSkills">Show Agent's Skills</a></td> > > The problem is when I click on the /agent/edit/1002077 link it executes the edit action but then also executes the getSkills action. > > Mappings: > > > 10:35:02,664 [Thread."http-bio-8080"-exec-8] RegexUrlMapping DEBUG : Created reverse URL mapping [/agent/edit/1002077] for parameters [{id=1002077, controller=agent, action=edit}] > 10:35:02,686 [Thread."http-bio-8080"-exec-8] RegexUrlMapping DEBUG : Created reverse URL mapping [/agent/getSkills/1002077] for parameters [{id=1002077, controller=agent, action=getSkills}] > > When I click the edit link: > > 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [500] > > 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [/] > 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [/misc/(*)] > 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [/dev/(*)/(*)] > 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Attempting to match URI [/agent/edit/1002077] with pattern [/(*)/(*)?/(*)?] > 10:36:02,307 [Thread."http-bio-8080"-exec-10] DefaultUrlMappingsHolder DEBUG : Matched URI [/agent/edit/1002077] with pattern [/(*)/(*)?/(*)?], adding to posibilities > > > The actual actions in the controller: > > def getSkills() { > def id = params.id > def agentSkillDtos = agentService.getSkillsForAgent(id) > render agentSkillDtos as JSON > } > > def edit() { > def debugger = params.id //Just so I can set a breakpoint here in the debugger > render(view: 'edit') > } > > What ends up happening if I click the edit link, is it executes the edit action,then executes the getSkills action. Then I get a page of JSON in the browser since that is the last render executed. > > Can anyone provide any insight? > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by mjparme
Don't start your action name with "get" because I believe it's then treated as a property getter and gets called on object creation. This is why it is being called when you go to edit.
Thanks, Bobby |
|
I changed my action name to "retrieveSkills" and the problem did indeed go away.
Thanks! That was puzzling the hell out of me. On Jan 4, 2012, at 10:57 AM, bobbywarner wrote: > Don't start your action name with "get" because I believe it's then treated > as a property getter and gets called on object creation. This is why it is > being called when you go to edit. > > > Thanks, > Bobby > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Click-link-result-in-two-actions-getting-executed-grails-2-0-tp4261969p4261995.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
