grails-controller

how to use session in grails

拈花ヽ惹草 提交于 2019-12-02 21:06:15
I am new to grails. And I have to work with session. I have seen the session documentation. But no idea where to put the code in my controller. I have a page for student creation names createStudent. Now I want that this page only be access able when the user will be in session. Now how can I do it. Should I have to set the user in a variable at the time of login. Can anyone please help me on this ? def index() { def user = session["user"] if (user){ redirect(controller: 'admistratorAction', action: 'createUser') }else{ redirect(controller: 'login', action: 'index') } } You could use the

Handling parameters from dynamic form for one-to-many relationships in grails

浪尽此生 提交于 2019-12-02 02:12:50
问题 My main question here is dealing with the pramas map when having a one-to-many relationship managed within one dynamic form, as well as best practices for dealing with one-to-many when editing/updating a domain object through the dynamic form. The inputs for my questions are as follows. I have managed to hack away a form that allows me to create the domain objects shown below in one Dynamic form, since there is no point in having a separate form for creating phone numbers and then assigning

Creating a Grail Jquery Modal Window and Form posting with ajax?

半城伤御伤魂 提交于 2019-12-02 01:45:42
问题 I have the following code : <body> <div id="dialog-form" title="Create a new Comment"> <form> <fieldset> <label for="name">Enter your Comment Please </label> <textarea rows="6" cols="2" name="commentArea" id="commentArea" ></textarea> </fieldset> </form> </div> <button id="create-user">Create new user</button> </body> and my Modal Window using jquery-UI <g:javascript> $(function(){ $("#dialog-form").dialog ({ autoOpen:false, height:300, resizable:false, width:350, modal:true, buttons: {

Handling parameters from dynamic form for one-to-many relationships in grails

故事扮演 提交于 2019-12-02 00:59:32
My main question here is dealing with the pramas map when having a one-to-many relationship managed within one dynamic form, as well as best practices for dealing with one-to-many when editing/updating a domain object through the dynamic form. The inputs for my questions are as follows. I have managed to hack away a form that allows me to create the domain objects shown below in one Dynamic form, since there is no point in having a separate form for creating phone numbers and then assigning them to a contact, it makes sense to just create everything in one form in my application. I managed to

Creating a Grail Jquery Modal Window and Form posting with ajax?

☆樱花仙子☆ 提交于 2019-12-02 00:52:33
I have the following code : <body> <div id="dialog-form" title="Create a new Comment"> <form> <fieldset> <label for="name">Enter your Comment Please </label> <textarea rows="6" cols="2" name="commentArea" id="commentArea" ></textarea> </fieldset> </form> </div> <button id="create-user">Create new user</button> </body> and my Modal Window using jquery-UI <g:javascript> $(function(){ $("#dialog-form").dialog ({ autoOpen:false, height:300, resizable:false, width:350, modal:true, buttons: { "Attach Comment": function() { alert('assum it already submitted'); // ? ? ? this time what can i add to

Grails Redirect Post-Logout Using spring-security-core-3.0.6+

五迷三道 提交于 2019-11-30 21:26:29
In spring security version 3.0.6, which fixed a CRLF logout exploit ( https://jira.springsource.org/browse/SEC-1790 ) they disabled the use of the 'spring-security-redirect' parameter. Default support for the redirect parameter in logout URLs has also been removed in 3.0.6. In 3.1 it already needs to be enabled explicitly. Is there a way to turn the redirect parameter back on, so that I can dynamically redirect in my Grails Spring Security Logout Controller? LogoutContoller.groovy def user = springSecurityService.currentUser if (params.redirect) { // this needs to log the user out and then

Grails 2.2.0 Support in Eclipse

时光总嘲笑我的痴心妄想 提交于 2019-11-30 21:02:53
I am trying to create a grails 2.2.0 project using eclipse-jee-juno. It gives me an error Groovy compiler level expected by the project does not match workspace compiler level. Project compiler level is: 1.8.X Workspace compiler level is 1.7.X Go to Project properties -> Groovy compiler to set the Groovy compiler level for this project. Background : I have installed grails 2.2.0 and I am able to create and run a sample project/controller by using the command line (not eclipse) Grails 2.x need groovy 1.8+ to work. In eclipse, right click your project, select 'properties' from menu and go to

Reading out all actions in a Grails-Controller

▼魔方 西西 提交于 2019-11-30 14:21:31
I need to read out all available actions from any controller in my web-app. The reason for this is an authorization system where I need to give users a list of allowed actions. E.g.: User xyz has the authorization for executing the actions show, list, search. User admin has the authorization for executing the actions edit, delete etc. I need to read out all actions from a controller. Does anyone has an idea? This will create a List of Maps (the 'data' variable) with controller information. Each element in the List is a Map with keys 'controller', corresponding to the URL name of the controller

Grails data binding - command objects with Lists

白昼怎懂夜的黑 提交于 2019-11-30 06:49:56
问题 Grails 1.3.7 Trouble with data binding Command objects that have List content. Example Command: class Tracker { String name String description List<Unit> units = new ArrayList() } class Unit { String name Long unitMax Long unitMin } create GSP for Tracker has the Unit fields. One example: <g:textField name="units[0].unitMax" value=""/> TrackerController save method: def save = { Tracker trackerInstance -> trackerInstance = trackingService.saveOrUpdateTracker(trackerInstance) } But, always

Inject grails application configuration into service

♀尐吖头ヾ 提交于 2019-11-29 00:57:25
I'm creating a grails service that will interact with a 3rd party REST API via a Java library. The Java library requires credentials for the REST API by means of a url, username and password. I'd like to store these credentials in configuration/Config.groovy , make them available to a service and ensure that credentials are available to the service before it requires them. I appreciate that grailsApplication.config is available to controllers and that through a method of a service the relevant config values can be provided to the service, such as this: package example class ExampleController {