How to use Madvoc Action macros urls within a groovy script?

12 views
Skip to first unread message

BloodySmartie

unread,
Feb 25, 2014, 2:33:20 AM2/25/14
to jod...@googlegroups.com
Hi there!

I'm using Madvoc in my web applications since a year now with very pleasant results. As a next step, i'd like to switch a class file, that contains Madvoc actions, to Groovy. Unfortunately, it seems to be not as easy as i thought, because the macros i defined are in conflict with the GString - feature of Groovy. 

So the following Groovy code can't be compiled:
package de.medienmixer.healthcare.web.actions.root

import jodd.madvoc.meta.Action
import jodd.madvoc.meta.MadvocAction

@MadvocAction
class TestActions {


    @Action("/foo/${bar}")
    private String printfoo(){

    }

}


Is there a way to work around this? If not, i'd like to propose to add a second char beside "$" to mark a macro that will work with GString.

Best regards,

David

jodder

unread,
Feb 25, 2014, 4:04:18 AM2/25/14
to jod...@googlegroups.com
Hey Bloody Smartie David :))

Very glad that Madvoc works for you! Also, your idea of writing Madvoc actions in Groovy is very cool, always wanted to explore that option :)

Now, Im not a Groovy expert, but did you try to escape GString? Afaik there are two ways:

  1. escape the '$' as '\$'
  2. use ' instead of " as string delimiter
Please let me know if this works for you. If not, it would be really easy to add another option as you asked for - just let me know :)

May the code be with you!

BloodySmartie

unread,
Feb 25, 2014, 4:33:45 AM2/25/14
to jod...@googlegroups.com
Of course! I should've thought of escaping by myself!! You're right - escaping with a backslash works perfectly with all my present actions. Thanks once again :) 

David
Reply all
Reply to author
Forward
0 new messages