grails-controller

How to extend/override controller actions of plugins ?

The plugin (Nimble 0.3) I am using in my grails application, includes some controllers and associated actions. I want to change (slightly) some actions behavior, and I was wondering how I can achieve that. Can I create a child controller that inherits from my plugin controller and override some of the action implementation? Or, can I c...

RuntimeError handling in Grails using View-Controller-Service architecture

I have following situation (simplified, of course): MyDomain.groovy: class MyDomain { MyAnotherDomain anotherDomain // lazy loaded } MyService.groovy: class MyService { boolean transactional = true def doSomething(id) { // ... some code... } } MYController.groovy: class MyController { def myService def doAction = { ...

How to obtain handle to Grails datasource

I want a handle to connection object in grails controller class (written in groovy). I read somewhere that I need to first obtain datasource object and call a method getConnection on it to get the connection object. I am unable to find how to obtain the datasource object in grails controller. Kindly help. ...

How to force grails to download csv files ?

In my gsp view, I have this code : <g:each in="${fileResourceInstanceList}" status="i" var="fileResourceInstance"> <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> <td>${fileResourceInstance.decodeURL()}</td> <td><a href="${createLinkTo( dir:"/upload_data/datasets/ds"+signalDataInstance.datasetID , file: fileResourceInstance.decodeURL(),...

Grails: Services VS Groovy classes

Documentation says: The Grails team discourages the embedding of core application logic inside controllers, as it does not promote re-use and a clean separation of concerns. I have one API controller and a few Groovy classes in src/groovy folder. Those classes just implements my application logic so actions in API controll...

Not able to save extjs combo using grails controller

Hi all, I am a newbie to grails/extjs I am developing a web based config tool for my team .My issue is with comboboxes of extjs I have three remote comboxes(many to one hibernate mappng).I am using hiddenName to submit its value field(which is id primay key of database) instead of its display field which is name which i get by renderin...

Groovy Grails, How do you stream or buffer a large file in a Controller's response?

Hi Guys I have a controller that makes a connection to a url to retrieve a csv file. I am able to send the file in the response using the following code, this works fine. def fileURL = "www.mysite.com/input.csv" def thisUrl = new URL(fileURL); def connection = thisUrl.openConnection(); def output = connection.content.t...

rails use counts in diferent views

Hello i guess this is going to be pretty noob question.. But.. I have an scaffold called list, which has_many :wishes. And with that information in my model, I can in my list view use this code <%=h @list.wishes.count %> well now I have made an controller called statusboard.. And in that' I have 3 functions.. Or how to say it.. b...

Reading out all actions in a Grails-Controller

Hi, i need to read out all available actions from any controller in my web-app. The reason for this is an authorization system where i need to give users a list of allowed actions. E.g.: User xyz has the authorization for executing the actions show, list, search. User admin has the authorization for executing the actions edit, delet...

How to access controller dynamic properties within a base controller's constructor in Grails?

Basically, I want to be able to assign objects created within filters to members in a base controller from which every controller extends. Any possible way to do that? Here's how I tried, but haven't got to make it work. What I'm trying to achieve is to have all my controllers extend a base controller. The base controller's constructor...

Grails - Very Simple Set Collection Value Not Working

Controller for a Bug: this is the create method for a bug, I printed out bugInstance.activities and it had my activity object in it def create = { def bugInstance = new Bug() def activity = new Activity(description:"created") bugInstance.properties = params bugInstance.addToActivities(activity) ...

Grails 1.3.3: controller.redirectArgs.action not populated

Does anyone knows what happened to controller.redirectArgs.action in the latest version of Grails (1.3.3)? It used to work properly but now I get NPE when I use it. class FooController { def someRedirect = { redirect(action:"bar") } } class FooControllerTests extends grails.test.ControllerUnitTestCase { void testSom...

Redirect to controller with multiple parameters on Grails

Hi All, I am developing a web app in Grails and I need to redirect my current page to another controller, passing to it multiple parameters. The exact scenario will be to have a from with multiple SELECT menus and have on them all a call to this controller on their "onChange" property, passing to it the current value of all the SELECT ...

Rewriting URL for the default action in controllers

I'm having trouble rewriting URL's in Grails: I've got 2 controllers BlogController and ProjectsController each with a default def index = { } and matching view. Now when I create the following links: <g:link controller="blog">Blog</g:link> <g:link controller="projects">Projects</g:link> They get translated to http://localhost:8080/...

Handling parameters from dynamic form for one-to-many relationships in grails

My main question here is dealing with the pramas map when having a one-to-many relationship managed within one dynamic form, as well as best practices for dealing with one-to-many when editing/updating a domain object through the dynamic form. The inputs for my questions are as follows. I have managed to hack away a form that allows me ...

Grails: Unable to get model data from controller to view

Hi, I have been using Grails for last 3 weeks (learning and working). I have been working on porting a JSP/Servlet application to Grails and it has been absolute "fun" porting the application. I have facing an issue and have been searching, reading but could not solve it yet. In the GSP page I have a textfield and search button where ...

How to handle correctly a URL having twice the same parameters with same values?

Using Grails 1.3.3, when requesting url link: /myapp/mycontroller/myaction?p1=v1&p2=v2&p1=v1 then params injected value into Grails controller will contain : assert params.p1== ['v1','v1'] It would have been logical to me that params.p1 equals to 'v1', no? In any case, is there any way to change this behavior? Thank you. ...

Grails + WS Client throw an CXF exception

I'm new in grails, and trying to build a backend for my webservice, the apps only access the webservice provided not access to databases directly. package backend import org.grails.plugins.wsclient.service.WebService class BackendController { WebService webService def index = { def wsdlUrl = "http://localhost8080/Ba...

grails webflow params problem

def createFlow = { println "1" def conferenceInstance = new Conference () start { println "2" action { println "3" flow.planAccountExistList = Account.findAllByPlanIsNotNullAndCustomer(session.customer) println "4" } println "5" on('success').to('accounts') println "6" } accounts { print...

How to redirect from a controller using a named URL mapping?

I have a URL mapping as below: static mappings = { name register: "/register" { controller = "account" action = "createuser" } } and I want to redirect using this mapping from a controller with something like: redirect mapping:'register' Unfortunately, unlike createLink tag lib, it seems that...