Quantcast

grailsApplication.config, static method, grails 2.0

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

grailsApplication.config, static method, grails 2.0

Gianluca Sartori
Hi guys,

I'm creating a Menu static class to handle menus in my app. I'd like to setup the menu structure in the Config.groovy file.
What's the preferred way to access grailsApplication from a static method in grails 2.0 now that ConfigurationHolder is deprecated?

Many thanks,
G

Gianluca Sartori
--
Cell. +39 347 0494840

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: grailsApplication.config, static method, grails 2.0

Ian Roberts
On 22/11/2011 11:23, Gianluca Sartori wrote:
> Hi guys,
>
> I'm creating a Menu static class to handle menus in my app. I'd like to
> setup the menu structure in the Config.groovy file.
> What's the preferred way to access grailsApplication from a static
> method in grails 2.0 now that ConfigurationHolder is deprecated?

The preferred option if at all possible is to refactor your code so you
don't need to... Does this have to be static or could it be a singleton
service (which you can autowire into other artefacts and access from GSP
views and layouts using
${grailsApplication.mainContext.menuService.whatever()})?

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: grailsApplication.config, static method, grails 2.0

Gianluca Sartori
That could be a service, definitely. Tnx for the hint Ian!
G

Gianluca Sartori
--
Cell. +39 347 0494840



On Tue, Nov 22, 2011 at 12:41 PM, Ian Roberts <[hidden email]> wrote:
On 22/11/2011 11:23, Gianluca Sartori wrote:
Hi guys,

I'm creating a Menu static class to handle menus in my app. I'd like to
setup the menu structure in the Config.groovy file.
What's the preferred way to access grailsApplication from a static
method in grails 2.0 now that ConfigurationHolder is deprecated?

The preferred option if at all possible is to refactor your code so you don't need to... Does this have to be static or could it be a singleton service (which you can autowire into other artefacts and access from GSP views and layouts using ${grailsApplication.mainContext.menuService.whatever()})?

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: grailsApplication.config, static method, grails 2.0

dzava
I guess you've decided to follow a different path, but anyway if you still need to know how to access the grailsApplication from a static method, take a look at Burt's blog post here http://burtbeckwith.com/blog/?p=993 and especially at the comments where I'm asking a related quesiton.

In addition, since you're trying to handle menus in your app, you might be interested in the navigation plugin: http://grails.org/plugin/navigation

Regards,
Dimitris


On Tue, Nov 22, 2011 at 4:39 PM, Gianluca Sartori [via Grails] <[hidden email]> wrote:
That could be a service, definitely. Tnx for the hint Ian!
G

Gianluca Sartori
--
Cell. <a href="tel:%2B39%20347%200494840" value="+393470494840" target="_blank">+39 347 0494840



On Tue, Nov 22, 2011 at 12:41 PM, Ian Roberts <[hidden email]> wrote:
On 22/11/2011 11:23, Gianluca Sartori wrote:
Hi guys,

I'm creating a Menu static class to handle menus in my app. I'd like to
setup the menu structure in the Config.groovy file.
What's the preferred way to access grailsApplication from a static
method in grails 2.0 now that ConfigurationHolder is deprecated?

The preferred option if at all possible is to refactor your code so you don't need to... Does this have to be static or could it be a singleton service (which you can autowire into other artefacts and access from GSP views and layouts using ${grailsApplication.mainContext.menuService.whatever()})?

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email






If you reply to this email, your message will be added to the discussion below:
http://grails.1312388.n4.nabble.com/grailsApplication-config-static-method-grails-2-0-tp4095278p4095916.html
To unsubscribe from Grails, click here.
NAML

Loading...