Sunday 15 May 2011

Grails How to get username in javascript? -



Grails How to get username in javascript? -

i working on grails application , want hide gui elements dynamically added via javascript. hence need username (and userrole) variable in js code. tried use

<g:set var="user" value="${sec.username()}" />

but varibale user not visible in js. know utilize ajax request username / role controller, isn't there easier / faster way?

you set current js context on page load:

<g:javascript> window.username = '${sec.username}'; </g:javascript>

and utilize username variable in javascript

javascript grails spring-security

No comments:

Post a Comment