Calling tags as methods from custom groovy classes

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

Calling tags as methods from custom groovy classes

Gary Affonso
In grails, you can access tag-logic by calling the tags as methods.  The docs indicate this call-tags-as-methods functionality is available in controllers, tag libraries, and .gsp views.  It's a great feature, I use it a lot.

I've got a groovy class (a CurrencyPropertyEditor) that I'd like to use the grails <g:format> tag in.  Specifically, I'd like to call that tag as a method from within my CurrencyPropertyEditor groovy class.

Is there some magic I can mix-in to my CurrencyPropertyEditor class that will let me call tags-as-methods just like I  can from Controllers and tag libraries?

Thanks!

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Calling tags as methods from custom groovy classes

Marc Palmer Local

On 24 Jul 2012, at 06:25, Gary Affonso wrote:

> In grails, you can access tag-logic by calling the tags as methods.  The docs indicate this call-tags-as-methods functionality is available in controllers, tag libraries, and .gsp views.  It's a great feature, I use it a lot.
>
> I've got a groovy class (a CurrencyPropertyEditor) that I'd like to use the grails <g:format> tag in.  Specifically, I'd like to call that tag as a method from within my CurrencyPropertyEditor groovy class.
>
> Is there some magic I can mix-in to my CurrencyPropertyEditor class that will let me call tags-as-methods just like I  can from Controllers and tag libraries?


Pro tip: Just use the standard Java text formatting classes.

You don't want to be bringing in taglib runtime issues into your property editor - i.e. requiring a current request etc.

Tags are meant for UI rendering, not mutating properties between client and model.

Marc
~ ~ ~
Marc Palmer
Freelancer (Grails/Groovy/Java/UX)

I offer commercial support for Grails plugins from as low as $50/mo.
For details see: http://grailsrocks.com

Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc
Contributor @ http://grails.org |  Founder @ http://noticelocal.com
Developer @ http://weceem.org | Member @ http://spottymushroom.com
Twitter: http://twitter.com/wangjammer5 


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Calling tags as methods from custom groovy classes

Gary Affonso

On Jul 24, 2012, at 1:56 AM, Marc Palmer wrote:

>
> On 24 Jul 2012, at 06:25, Gary Affonso wrote:
>
>> In grails, you can access tag-logic by calling the tags as methods.  The docs indicate this call-tags-as-methods functionality is available in controllers, tag libraries, and .gsp views.  It's a great feature, I use it a lot.
>>
>> I've got a groovy class (a CurrencyPropertyEditor) that I'd like to use the grails <g:format> tag in.  Specifically, I'd like to call that tag as a method from within my CurrencyPropertyEditor groovy class.
>>
>> Is there some magic I can mix-in to my CurrencyPropertyEditor class that will let me call tags-as-methods just like I  can from Controllers and tag libraries?
>
>
> Pro tip: Just use the standard Java text formatting classes.
>
> You don't want to be bringing in taglib runtime issues into your property editor - i.e. requiring a current request etc.
>
> Tags are meant for UI rendering, not mutating properties between client and model.

Got it!  Thanks!

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

    http://xircles.codehaus.org/manage_email