help with uservoice integration

8 views
Skip to first unread message

Warner Onstine

unread,
Feb 27, 2011, 4:15:37 PM2/27/11
to grails-startup...@googlegroups.com
Hi all, I'm trying to integrate UserVoice support (UserVoice.com) into
my application. I'm doing SSO, so I need to pass some info along to
their widget.

It's fairly complex so I'm doing all of it server side through a
service. I'm now in a quandary as to how to get this string down to
the actual JavaScript.

I'm sure I'm missing something obvious, but here's what I have:
_uservoice.gsp - which has a variable token I can push into it from a controller
TokenGeneratorService - which builds up the token from the current
logged in user and encodes that to send it back to the UserVoice site
when the feedback button is clicked.

I don't like that this requires that for every page I want this on I
need to add this service call and add the 'token' variable to the
model being passed down to the render.

Can anyone see a better way to do this?

-warner

Mike Brocious

unread,
Feb 27, 2011, 6:06:30 PM2/27/11
to grails-startup...@googlegroups.com
Is it possible for you to use the /views/layout/main.gsp (Sitemesh template) to host the Javascript?  That's run for every page.

You could write a filter that gets invoked on every controller action and add something the model.  We do this to add some standard user info to every page.  Maybe something like this in grails-app/conf/MyFilters.groovy:

class MyFilters {  

    def myService

   

    def filters = {       

        addUserVoiceStuffToModel(controller: '*', action: '*') {

            after = { model ->

                    model?.userVoiceStuff = myService.getUserVoiceStuff()

                }

        }

    }

}


Mike



--
You received this message because you are subscribed to the Google Groups "Grails Startup Support Group" group.
To post to this group, send email to grails-startup...@googlegroups.com.
To unsubscribe from this group, send email to grails-startup-suppo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/grails-startup-support-group?hl=en.


Warner Onstine

unread,
Feb 27, 2011, 6:15:07 PM2/27/11
to grails-startup...@googlegroups.com
That might work! I have never futzed with filters so I'll give that a
shot and see what happens.

-warner

Warner Onstine

unread,
Feb 27, 2011, 7:37:19 PM2/27/11
to grails-startup...@googlegroups.com
That did the trick! Thanks so much, greatly appreciated.

-warner

On Sun, Feb 27, 2011 at 4:15 PM, Warner Onstine <war...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages