Simple questions

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple questions

wyrdhamster@gmail.com
I know this probalby is noob question but can't find the answer to it in documentation.

Where to put your custom made functions? I want to make function to change empty strings in to string having '-' marks, but want's to use it A LOT and "copy-paste" to each Controller is just illogical. I should put it to Scripts folder? And how to recall them in Controllers?

Reply | Threaded
Open this post in threaded view
|

Re: Simple questions

ishe
make class in src/groovy or src/java



On Thu, 2010-07-22 at 11:20 -0700, [hidden email] [via Grails]
wrote:

> I know this probalby is noob question but can't find the answer to it
> in documentation.
>
>
> Where to put your custom made functions? I want to make function to
> change empty strings in to string having '-' marks, but want's to use
> it A LOT and "copy-paste" to each Controller is just illogical. I
> should put it to Scripts folder? And how to recall them in
> Controllers?
>
>
>
>
>
> ______________________________________________________________________
> View message @
> http://grails.1312388.n4.nabble.com/Simple-questions-tp2299111p2299111.html 
> To start a new topic under Grails - user, email ml-node
> +[hidden email]
> To unsubscribe from Grails - user, click here.
>


Reply | Threaded
Open this post in threaded view
|

Re: Simple questions

Dave Klein-2
You could also put it in a Service class and inject it where needed or you could create a codec and then it would automatically be available on all Strings. Look up codecs on grails.org

Dave

Sent from my iPhone

On Jul 22, 2010, at 11:32 AM, ig78 <[hidden email]> wrote:

make class in src/groovy or src/java



On Thu, 2010-07-22 at 11:20 -0700, [hidden email] [via Grails]
wrote:

> I know this probalby is noob question but can't find the answer to it
> in documentation.
>
>
> Where to put your custom made functions? I want to make function to
> change empty strings in to string having '-' marks, but want's to use
> it A LOT and "copy-paste" to each Controller is just illogical. I
> should put it to Scripts folder? And how to recall them in
> Controllers?
>
>
>
>
>
> ______________________________________________________________________
> View message @
> http://grails.1312388.n4.nabble.com/Simple-questions-tp2299111p2299111.html 
> To start a new topic under Grails - user, email ml-node
> +[hidden email]
> To unsubscribe from Grails - user, click here.
>

Igor


View this message in context: Re: Simple questions
Sent from the Grails - user mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Simple questions

lucastex
In reply to this post by ishe
for this kind of need is perfect to use metaprogramming and inject this methods into String for eg.

http://groovyconsole.appspot.com/edit/28001

Lucas Frare Teixeira .·.
- [hidden email]
- lucastex.com.br
- blog.lucastex.com
- twitter.com/lucastex


On Thu, Jul 22, 2010 at 3:32 PM, ig78 <[hidden email]> wrote:
make class in src/groovy or src/java



On Thu, 2010-07-22 at 11:20 -0700, [hidden email] [via Grails]
wrote:

> I know this probalby is noob question but can't find the answer to it
> in documentation.
>
>
> Where to put your custom made functions? I want to make function to
> change empty strings in to string having '-' marks, but want's to use
> it A LOT and "copy-paste" to each Controller is just illogical. I
> should put it to Scripts folder? And how to recall them in
> Controllers?
>
>
>
>
>
> ______________________________________________________________________
> View message @
> http://grails.1312388.n4.nabble.com/Simple-questions-tp2299111p2299111.html 
> To start a new topic under Grails - user, email ml-node
> +[hidden email]
> To unsubscribe from Grails - user, click here.
>


Igor


View this message in context: Re: Simple questions
Sent from the Grails - user mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Simple questions

wyrdhamster@gmail.com
Thanks for help, maybe you could show me even better way to do this if I say what I looking for. I need the function that on save methods of Domain Classes, if String propriety of object is empty , will change that String to that full of '-', on whole lenght of String propriety. What way do you think is best with this?