FAQ Database Discussion Community


Bootstrap datatable pagination only showing buttons but not working in Grails

twitter-bootstrap,grails,datatable,pagination
I am using Grails 2.4.2. and bootstrap datatable for Grails. All works fine for datatable in my index page except for pagination. It shows all the related buttons for pagination but don't paginate. Also there is another div where paginate also shown and work but not with datatable ? Here...

How to update a server side datatable on change a checkbox from outside of datatable

grails,datatables,datatables-1.10,grails-2.4
I am using data table with Grails. I have a check box outside the data table and on its event I want to load the table again with the check box value. Here are my attempts below : In my view where the check box is >> <g:checkBox id="wrapCheck" name="wrapCheck"/>...

How can I pass data between GSP and controller in Grails without storing in the database?

grails,controller,gsp
Is it possible to enter data in the GSP view and use this data in the controller inside the program to do some operations without storing this data in the domain. For example I have a g:textField and I enter my name. I want to be able to use the...

Grails: Do addTo* and removeFrom* require a call to save?

grails,gorm,grails-2.0,grails-domain-class
In the docs some examples have a call to save whereas some others do not. I'm assuming that addTo* needs the call to save whereas removeFrom* doesn't. Am I mistaken?

Sorting on nullable fields in GORM

grails,gorm,grails-3.0
I'm trying to figure out how to sort on multiple fields in Grails 3, one of which may or may not be null. I have this Book domain: class Book { String title String sortTitle static constraints = { title blank: false sortTitle nullable: true } } Books with titles...

Error when using angular with Grails

angularjs,grails
Here is my index.gsp <!DOCTYPE html> <html ng-app="myApp"> <head> <title>my app</title> </head> <body> <input type="text" data-ng-model="test"/> {{test}} </body> <script src="/js/angular.min.js"></script> </html> When I build an app, There is an error like this, Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=myApp&p1=Error%3A%…20at%20d%20(http%3A%2F%2Flocalhost%3A8000%2Fjs%2Fangular.min.js%3A17%3A381)...

Grails 2.4.4: services does not inject: integration test

grails,integration-testing,spock
I have service with dependency service like: class ParserService { def depService; private def parseLine(lineParts) { ... def set = depService.findItemByName(tmpModule.name);//depService == null ... I try to implement integration test like: @TestFor(ParserService) class ParserServiceTest extends IntegrationSpec { def "should not parse comment"() { when: ... def resultList = service.parseAnnotations(inputStream); resources.groovy:...

run-script alternative in Grails 3

grails
In Grails 2 there was a great run-script command that allowed to execute custom Groovy script with all project classes available. Is there something similar in Grails 3? P.S. The only way we found is defining out own RunScriptCommand which implements ApplicationCommand. This command requires a separate gradle project, which...

Grails customised message not working

grails,error-handling
Github source code https://github.com/grails-samples/grails-petclinic Customised message has been specified, unfortunately it doesn't work. owner.firstName.blank=You must specify a first name It shows error message "Property [firstName] of class [class org.grails.samples.Owner] cannot be null" instead of "You must specify a first name". I have found the same issue in this screencast http://grails.org/screencast/22...

Grails 2.4.4 spring security role doesn't apply to user

java,spring,grails,spring-security,spring-annotations
I have controller: class AdminController { def springSecurityService @Secured(['ROLE_ADMIN', 'ROLE_USER']) def index() { render "test"; } And user with role ROLE_ADMIN in the table: But, when I use: springSecurityService.getPrincipal().getAuthorities() There is only one role: ROLE_NO_ROLES Why? def loggedInUser = springSecurityService.currentUser; returns correct user. Config: ... grails.plugin.springsecurity.userLookup.userDomainClassName = '...' grails.plugin.springsecurity.userLookup.authorityJoinClassName =...

grails respond error page with status from Url mapping file

grails,grails-controller
Can I respond error pages with status code from url mapping file. Basically I have a DemoController with Action Index. And I have created URL Mapping for "/" -> demo/index. So now index action of demo controller is accessible by two urls i.r. /demo/index and /. Now I want that...

Error domain class not found

osx,grails,osx-yosemite
I am able to create app using ($ grails create-app MyDomain) but not able to move forward with $ grails generate-all MyDomain. I made sure that I do have the domain generated with the proper name/spelling (by going physically into the local folder on my machine), all looks ok. The...

What is the proper way to setup integration tests in grails 2.5 using junit?

grails,junit,dependency-injection,integration-testing
With grails 2.2 the following code (which is an integration test for a GORM class) was working fine: public class DbDeploymentIntegrationTests extends GroovyTestCase { DeploymentStorageImpl deploymentStorage DeploymentService deploymentService @Override protected void setUp() { super.setUp() deploymentStorage = deploymentService.deploymentService.deploymentStorage } ... } When I updated to grails 2.5, this is now failing:...

How to redirect user to different pages after logout with Spring Security and Grails

grails,spring-security
I am new to Groovy and Grails. I have developed an application using the Spring Security plugin using a database requested request map. I want a custom redirection to the home pages after logout according to the roles. If the user is ROLE_ADMIN, after logout he would be redirected to...

Error in SQL syntax MySQLSyntaxErrorException in Grails

mysql,grails
I do request to MySQL database, which searches data in table by criteria: def tableAcounting(){ def user = Person.findByUsername(springSecurityService.currentUser.username) def cafee = user.cafee def tablesQuery = TablePlacesInfo.createCriteria() def tables = tablesQuery.list { //AN ERROR SHOW ON THIS STRING 'in'("hall", HallsZones.findAllByCafee(cafee)) } def halls = cafee.halls But I get such error:...

File upload with grails and jquery

jquery,grails
I have a form with multiple inputs plus a doc or pdf file upload. //Multiple input fields are here then upload -> <div class="controls"> <div class="fileupload ${ person?.attachment ? 'fileupload-exists' : 'fileupload-new' }" id="attachment" data-provides="fileupload" data-name="attachment"> <span class="btn btn-file"> <span class="fileupload-new">Add</span> <span class="fileupload-exists">Change</span> <input type="file" /> </span> <span class="fileupload-preview"></span>...

grails DataSource.groovy refer bean for decoding password

grails
Referring https://jira.grails.org/browse/GRAILS-3620, we need to specify a class with static methods to decode the encrypted password in DataSource config. For passwordEncryptionCodec property, is it possible to refer to a bean defined in resources.xml or any other grails bean definition files? For ex: having a decrypted Properties bean in resoures.xml or...

Grails updating values in form using Ajax

jquery,grails
I have two groups of radio buttons, the first group represents size and the second group represents quantity along with price. I'm trying to update the price next to quantity with Ajax when changing the size radio has been changed. What I have thus far. <script> $(document).ready(function(){ $("input[name*='size']").click(function() { ${remoteFunction(...

How to pass params into Services that I get from the gsp and I have in my Controller in Grails

grails,service,gsp
I've got the params that a user enter in a g:textField in my controller when I call method save(), and I need to use this value in my services. How can I pass the params that I have in my controller to my services or is possible pass this data...

How can convert data that I have stored as a string into a map

string,grails
I have one String stored in my DDBB, for example in my column data I have this String: "name=James castle&age=20" and I want, in my Services, converted to a map I'm trying something like: List <NameValuePair> parameters = myDomainInstance.data if (org.externalDeliveryParameters){ parameters = URLEncodedUtils.parse(org.externalDeliveryParameters, StandardCharsets.UTF_8) } I get this error:...

passing backbone collection to view

grails,backbone.js,handlebars
I'm just starting out with backbone / grails and i've been struggling to figure out how to get everything to work. I'm building a pricing configurator where a user selects a product type from radio group A and radio group B containing the quantity / pricing / discount data will...

Execute controller function in Grails via Ajax

javascript,jquery,ajax,grails,gsp
I am a novice with ajax in Grails. I want to try to execute a controller method from gsp-code from ajax. This is part of my gsp-code: <g:select optionKey="id" name="region.id" id="region" from="${region}" noSelection="[null:' ']" onchange="categoryChanged(this.value);" ></g:select> <div> <b>Sub-Category: </b> <span id="subContainer"></span> </div> <script> function categoryChanged(regionId) { $.ajax({type:'POST',data:'regionId='+regionId,...

Cannot initialise subclass of command object using properties?

grails
I am using Grails 2.4.4. In a controller I have used a command object for handling input from a view. That works fine. But now I want to use subclasses for command objects. Depending on some id in the params I want create a specific subclass for the command object....

How to declare javascript asset in the view to be rendered within the footer using Grails Asset Pipeline

grails,grails-plugin
Since there is no deferred option for: <asset:javascript src="custom_view_script.js"/> What else can be used, outside of resource plugin, to place view specific script right before the closing body tag and without declaring it globally in layout? I do know about: <asset:deferredScripts/> but that only handles on page script and not...

Recommended approach to multi-threading in Grails 3

grails,grails-3.0
In Grails 2 I used the Executor plugin to perform multi-threading operations in services and it worked very well. Like most Grails plugins it hasn't been ported over to Grails 3 yet. The GPars library is/was another option for multi-threading, but with Codehaus shutdown I am reluctant to use it....

Encryption of strings using AES 128 in Java/grails

java,grails,encryption,aes
I would like to encrypt 3 strings using AES 128 in Java / Grails, and using the code below, but i get the error "An error occurred when encrypting", can someone tell me what is wrong with my code, how to fix it. thanks in advance and to Stackoverflow. String...

Grails JAX-RS Calling a class in src/groovy giving error - Message: No signature of method: is applicable for argument types

grails,groovy,jax-rs
While developing the rest api using jaxrs plugin I need to create some common class which I have created in "src/groovy". Below is the class class ValidateToken { String validate(String token){ println(token) return "test" } //... In resource file(jaxrs) this is what I am doing def instance=ValidateToken.validate("test") This throws error...

Grails: In migrating/updating databases, what is the MD5SUM for?

mysql,database,grails,md5
Probably a rookie question, so have patience. When I use grails dbm-update-sql I get a generated sql file to update the database to match my domain classes. In the generated SQL file There are INSERTS into the DATABASECHANGELOG. INSERT INTO `DATABASECHANGELOG` (`AUTHOR`, `COMMENTS`, `DATEEXECUTED`, `DESCRIPTION`, `EXECTYPE`, `FILENAME`, `ID`, `LIQUIBASE`, `MD5SUM`,...

Grails resource tag generating wrong link

javascript,css,grails,resources
I am working on a project in which different modules are divided in different custom created plugins. As for example- AccountingPlugin UiPlugin Etc.... So like now I have all the UI related stuff inside UiPlugin and I am working on Accounting plugin and I have controllers, services and views of...

Retrieving Array of Object from params on Grails

arrays,ajax,grails
I'm passing an Array on a POST request using an AJAX call, but not a simple one, rather an Array of Objects: var param = { ..., branches: { 0: { address: "...", telephone: "...", fax: "...", ... }, ... nth: { address: "...", telephone: "...", fax: "...", ... }...

unable to resolve class org.apache.commons.net.ftp in grails

grails,apache-commons
I am developing a module in which some file need to be uploaded on a ftp server for that I have added the "commons-net-3.3.jar" in my grails app & while using it import org.apache.commons.net.ftp.FTP import org.apache.commons.net.ftp.FTPClient import org.apache.commons.net.ftp.FTPClientConfig import org.apache.commons.net.ftp.FTPFile import org.apache.commons.net.ftp.FTPReply It is throwing the error unable to resolve...

Grails remote control plugin - Spring Security Configuration

grails,spring-security,geb,remote-control
Whenever I try to use the Grails Remote Control plugin, I get the following Exception. groovyx.remote.RemoteControlException: Error sending command chain to 'http://localhost:8080/******/grails-remote-control' [test] at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:65) [test] at groovyx.remote.client.RemoteControl.sendCommandChain(RemoteControl.groovy:114) [test] at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:73) [test] at...

Grails- how to verify the value of a params in gsp?

javascript,grails
I have to verify a value of a parameter which send from the controller. How can I do it in the gsp using ?

Alternative for g:select (multiple values)

javascript,jquery,grails,selection
I have a Domain Class Project with a one-to-many property users : static hasMany = [users: User] In my scaffolding code the view is created with: <div class="fieldcontain ${hasErrors(bean: projectInstance, field: 'users', 'error')} "> <label for="users"> <g:message code="project.users.label" default="Users" /> </label> <g:select name="users" from="${usermanagement.User.list()}" multiple="multiple" optionKey="id" size="5" value="${projectInstance?.users*.id}" class="many-to-many"/> </div>...

Grails command object validation with Ajax

ajax,validation,grails
In a Grails project I have a command object to validate submitted forms. This command obj. also has custom validators. The data is submitted with jQuery ajax ($.post). My question is how can I now map the data send with jQuery Ajax to the properties listed in the Command object?...

Grails 3.0.2 missing generate-views

java,grails,command-line,ide,ggts
I'm new to grails and I'm trying to get my first HelloWorld from it. I can generate it with the controller, but I can't create a view because it isn't listed in the Grails (3.0.2) list of command. Because any IDE support grails 3.*, I can't create it by that...

Use a different layouts/main.gsp based on environment in Grails

grails,build,gsp
I am trying to have two distinct layouts for my application. Most of the changes are CSS based, however some elements might also get moved around(such as moving a navbar from the top to the side). I decided the easiest would be is to have two main layouts, and pick...

Grails domain custom validator check uniqueness

grails,gorm
Can you check combination uniqueness of a field inside a custom validator in a Grails domain class? Long points String field1 String field2 Level level level validator {val,obj-> if(obj.points<1000){ //make sure level is unique with field 1 level unique: ['field1'] } else{ //make sure level is unique with field 2...

Strange behavior of ternary operator

grails,groovy
I observed strange behavior, in clean "test" application I have this simple controller: (Grails 2.5.0, Java Oracle 8u45, GNU/Linux Debian 7) package test class DiController { def ok() { double d = 0d int i = (int)d def r = [] r << i if (true) { r << i...

Grails produce seo friendly URLS

grails,seo
I'm very new to grails and I have some questions about creating views with SEO friendly URLs. Lets say I have a page I'd like to call used-products or https://www.sampledomain.com/used-products, how would I go about creating a view and have it resolve for used-products? Another example would be something like...

JSONException error Grails

json,parsing,grails,jsonslurper
Paring JSON file, using JsonSlurper My code is like below String url = 'https://urlThatIWantToGoto' String jsonFile = new JsonSlurper.parseText(new URL(url).text)) JSONArray jsonParse = new JSONArray(jsonFile) Whenever I run this code, I get a error printing as following Caught: org.codehaus.groovy.grails.web.json.JSONException: Expected a ',' or '}' at character 982 of "MyJSONFile" Funny...

Grails 2.3.9 - Error: ClassNotFoundException: grails.plugin.spock.test.GrailsSpecTestType

grails,grails-plugin,spock,grails-2.3
Whenever I enter the grails command: test-app I get this error: Error executing script TestApp: java.lang.ClassNotFoundException: grails.plugin.spock.test.GrailsSpecTestType (Use --stacktrace to see the full trace) In my BuildConfig.groovy I have: grails.project.dependency.resolution = { ... plugins { ... test ":spock:0.7" } } I've tried replacing it with compile ":spock:0.7" . I've also...

Named query on child joining two levels of parent tables

grails,gorm
Given class Store { String name static hasMany = [departments: Department] } class Department { String name static belongsTo = [store: Store] static hasMany = [products: Product] } class Product { String name Integer qty static namedQueries = { productsInStockByStore {store-> department { store { eq 'id', store.id } }...

Grails: How to get username of currently logged in user, and what imports does that require?

authentication,grails
I simply need the name of the currently logged in user. The same that gets displayed in gsp with <sec:username/>. I'm at a loss as to what to do. Here's previous answers and questions - they all seem to require some import and none of the solutions works for me:...

Keeping object states without persisting the data

grails
I am building a little web game using Grails and I feel like I am missing an important concept. A game involves an n*n grid. Each player plays its turn by clicking a cell. The code needs three Groovy classes: Game, Grid and Cell. I could make this game the...

No such property: id for class: java.lang.String

grails
I am sending the employee object from the Project_level controller to the _add_members view and then from there I am sending the employee object to the Project_permission controller. while saving the id the following error is coming: No such property: id for class: java.lang.String in the line :proj_permission.setId_of_employee(emp.id) class Project_levelController...

Where is the appropriate place for SQL scripts in a Grails project

grails,gorm
I've got a Grails plugin that exports domain objects so that several applications can share the same schema. We have a few SQL scripts for setting up some complex triggers, views and other functions that just don't really belong in GORM/Hibernate, at least not elegantly. I'd like to store the...

Intellij IDEA long processing for grails app with warning “too much output to process”

grails,intellij-idea,jvm
I new to Intellij for Grails app while run the app it execute lot of thing with the warning "Too much output to process" & takes comparatively more time to start the server. Below is the log screen (AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) at...

Grails formRemote 404 Not Found

grails
I'm having difficulties getting my ajaxform working properly. I'm using Grails 2.4.4 and have the following remoteForm code. view usedProducts <div id="updateMe"> <g:each in="${productList}" var="product"> ${product.item} Success1 </g:each> </div> <g:formRemote name="myForm" url="[controller:'product', action: 'save']" update="updateMe"> <g:textField name="item" required="" value="${newProduct?.item}" /> <g:submitButton name="Save" /> </g:formRemote> Controller ProductController def...

change input field value via javascript in grails

javascript,grails
In my Grails project I have a field that allows me to select between a list. After user has selected a value, I store the id of the related object. I would like that, after storing the id, I get a value related to the object with that id and...

Remove method of the List is not working

grails
I am creating a session variable in one controller-: List<Employee> emp = new ArrayList<Employee>() emp = Employee.findAllByLevel(proj_lev.level_no) session.employee_list = emp render(view: "add_members", model: [proj_lev:proj_lev , proj_lev_right:proj_lev_right , employee:session.employee_list]) In another controller I am accessing the session variable and using the remove method of the List but the list is not...

Grails logging auto inject

grails,logback
I use grails 3.0.2 and logback. How can I use this logger in my code, can I somehow autoinject it, like log.debug() in grails 2.x which was using org.apache.commons.logging.Log?

Log Grails Pre 3.0 startup time

grails
In Grails 2.x.x is it somehow possible to log the startup time? We are currently trying to optimize the application startup and having the startup time logged would help tremendously.

How to set a cron expression of cron job from controller in Grails

grails,cron,quartz-scheduler
I want to get a cron expression from a user through .gsp and want to set it as new cron expression of Dynamic Job from controller. Intially my cron expression was like "0 1 0 * * ?" but now want to change it to.. say String cronExpression="0 2 0...

OR condition in Grails Shiro tag

grails,tags,shiro
I am doing a two level menu and I want to show some entries if the user has certain permissions. I dont want to show the first level of the menu if the user doesn't have permissions to any other submenu because it would display an empty list of results....

[B cannot be cast to java.sql.Blob

grails,gorm
This is my domain class class TimesheetSubmission { Date submissionDate=new Date() String foreman String shift String jobId Date date byte[] xmlSubmission String xmlResponse static constraints = { submissionDate nullable: false foreman nullable: false shift nullable: false jobId nullable: false date nullable: false xmlSubmission nullable: true xmlResponse nullable: false } static...

Testing for the Default Value

grails,spock
I am just starting to write tests for a Grails app and I have watched this and read this and would like to use the tests to check that the constraints have been set properly. Now, while at it, I would figure one should also test if the default value...

Getting grails view as string?

grails,view,grails-controller
Can I get grails view as string in grails ? I have one view on location "/template/product.gsp" inside view folder. I can render it using render (view: "/template/product", model: [product: Product.get(1)]) It's working without any problem, But what I need is to get the rendering content as string. Because I...

alert grails pagination current offset value

grails,pagination
I am using Grails 2.4.2. I have a list which is using pagination. When I mouse hover a number or next page icon it shows current offset number as tool tip. Can I alert this offset number or get my list's current page offset number?

Grails 3.0 Searchable plugin

maven,grails
I've tried to use the searchable plugin in grails 3.0, but I am not sure wheather it is compatible or not. I've added compile "org.grails.plugins:searchable" to the dependencies. The build completes but yields a NotSearializableException: > Configuring > 1/1 projects > Resolving dependencies ':agent' > Resolving dependencies ': BUILD SUCCESSFUL...

Unmarshalling JSON to Groovy in Grails Date

jquery,ajax,json,grails
I am working Grails 2.4 and Ajax. On the client I build JSON data as follows: var data = { // ... not important date: new Date( parseInt($("#date_year").val()), parseInt($("#date_month").val()) - 1, parseInt($("#date_day").val())), // ... }; I send the date with jQuery Ajax: $.ajax({ url: '${createLink(controller: 'report', action: 'save')}', type: 'POST',...

How to define a url range for a Grails plugin

grails
I have a Grails app that should be extended by more than one own implemented Grails plugins. I import them in the BuildConfig.groovy just like other plugins. The Controller of each plugin can be called under the root url: http://localhost/application/<ctrlPlugin1> http://localhost/application/<ctrlPlugin1>/<endpoint1> http://localhost/application/<ctrlPlugin2> At this moment the controller names in plugin1...

grails one to many with additional column

grails,relationship,one-to-many
In my Grails project I need to have a 1:N relationship between two domain classes. So, I've created the following domain class: class Receipt_HealthService { Receipt receipt HealthService healthService int quantity = 1 static constraints = { } } and in Receipt I have the following: @NotNull static hasMany =...

Grails: Store audit record regardless of success/failure?

hibernate,grails,transactions,audit
In Grails, what is the recommended pattern to write an audit record for certain actions regardless of how the transaction ends? Example: Online user registration attempt that may fail for a number of reasons. Basic assumption, business logic is confined to transactional service methods. Underlying uncertainty: Should I abort a...

Error message always popping

grails
The following error is coming again and again on my Eclipse. I am working with Grails2.5 Also I am using jdk1.8.0_45 Also the following error is coming in my error log-: Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui". Error in JDT during AST creation....

grails message as argument of other message

grails,internationalization,taglib
I have this for example in my i18n messages_es.properties birds.label=Aves mammals.label=mamiferos reptiles.label=reptiles default.no.items.found=No se encontraron {0} And then I want to use the message, inside the template argument in my Grails .gsp Views: <g:message code="default.no.items.found" args="<g:message code='birds.label'/>"/> This of course doesn't work. But is there a way to make this...

showing null point exception when findAllBy - for session object

grails,gsp
I have already checked that session.parent_id and session.id_of_project is not null in the below code in gsp <g:if test="$session.parent_id"> <g:set var="permission" value="${Project_permission.findAllById_of_projectAndParent_id(session.id_of_project, session.parent_id)}"/> <g:each var="emp" in="${permission}"> <g:set var="employee2" value="${Employee.findById(emp.id_of_employee)}"/> <li class="parent_li"> <span class="badge red" title="Collapse this branch"> <i class="fa fa-minus-sign">...

Create domain classes according to given JSON file

json,parsing,grails,rendering
I'm new to Grails, and I'm stuck on the basic structure of my web-app So far I've implemented a Grails app that renders one JSON file to a readable table. example Given JSON file below { "abbreviation": "EXAMPLE", "guid": "31ac235e2-3ad3-43e3-1fd4-41e6dfwegf03", "metadata": { "dataOrigin": "Example" }, "rooms": [ ], "site": {...

Find instance by name where query is any part of its name, Grails

grails,gorm
In Java, the string search by its' substring goes like this: String string = "Madam, I am Adam"; b = string.matches("(?i).*i am.*"); How to find an instance in Grails by name where query is any part of its name?...

Error when executing Grails application in Spring Tool Suite

grails,spring-tool-suite
I get the following error when executing my Grails application in Spring Tool Suite: | Error 2015-06-12 18:19:18,357 [localhost-startStop-1] ERROR hbm2ddl.SchemaUpdate - Unsuccessful: alter table meta_data_master_template add index FK6FD57D1CFA081AA2 (protocol_id), add constraint FK6FD57D1CFA081AA2 foreign key (protocol_id) references protocol (protocol_id) | Error 2015-06-12 18:19:18,357 [localhost-startStop-1] ERROR hbm2ddl.SchemaUpdate - Cannot add or...

Getting the name of each field in JSON

json,parsing,grails
I'm trying to parse a random JSON file in Grails. First I need to get the name of each field For example, given below JSON file, { "abbreviation": "EX", "guid": "1209812-1l2kj1j-fwefoj9283jf-ae", "metadata": { "dataOrigin": "Example" }, "rooms": [ ], "site": { "guid": "1209812-1l2kj1j-fwefoj9283jf-ae" }, "title": "Example!!" } I want to...

Hibernate proxies - classes with unusual names

grails
While doing some GORM research to better my understanding of GORM, I was using a practice Grails project where I had a Pet domain class. I came across a casting error where I noticed in the error message there was a class with a name like Pet_$$_javassist_3. Is this a...

Use data-* attribute in grails g.link generated in tagLib

grails
Is there a way to use data- attributes in g.link generated by a tagLib? I want to store some DOM info instead of using params in the g.link which results in query parameters. Example: out << g.link(controller: "calendar", action: "info", params: [id: cal_id], data-info: "abc") { "click me " }...

Groovy - timestamp from minutes

oracle,grails,groovy,timestamp
I have an array or times/values coming back to be in an array like: [0, 60] Which are times in minutes, 0 = 12:00 a.m, 60 = 1:00 a.m. I am wanting to store these in an oracle database as timestamps. How do I convert minutes into timestamps in groovy?...

java.io.IOException: Permission denied while creating new file from Tomcat in Grails

tomcat,grails
I have a Grails application deployed on Tomcat 7. Here is my code fragment which tries to create a new file: def path = "/var/csvs" + file.fileItem.fileName def fileInputStream = file.inputStream File f = new File(path) if (!f.exists()) { f.createNewFile() } I get this exception: Permission denied. Stacktrace follows: java.io.IOException:...

Grails 2.4.4 generated controller test fails

unit-testing,grails
I have test for the save action of a controller. It just executes the action with correct params, but the problem is on the redirectedUrl line: it is null. Using the app, after saving the domain instance, I get the redirection to the show action and the show view is...

grails 3.0.1 scaffolded view does not show domain relationship

grails,scaffolding
I am following the example in the book "Grails a Quick-Start Guide" using Grails 3.0.1 with following domains package com.tekdays class TekEvent { static constraints = { name() city() description maxSize:5000 organizer() venue() startDate() endDate() } String city String name TekUser organizer String venue Date startDate Date endDate String description...

Could not mock return value of service

grails,spock
i have a problem with an controller test. I try to mock a return value of a service method, but it do not return a specific object and call the service method anyway. The Test-Method: def "shouldReturnStatus"() { given: controller.repairService.getRepair('123465') >> repair; when: controller.status(); then: response.text == '{"currentStatus":"Repair was found.","repairFound":true}'...

Can we give multiple things in the findAll

mongodb,grails
I have an Employee domain that has the Professional_id in it. Professional domain has a field called level in it. Now I want to extract all the Employee that are on same level. How can I write the query? I want something like def emp = Employee.findAllByProfessional_id(Professional.findAllByLevel(5)) Employee domain-: class...

Decode base64 image in Grails [duplicate]

grails,groovy
This question already has an answer here: Convert base64 string to image 3 answers I have a post api where I am sending a json string which contain the base64 encoded image.Below is the json string { "imageData":"base64encoded string", "status":"1" } where base64encode string is iVBORw0KGgoAAAANSUhEUgAAAHgAAACgCAIAAABIaz/HAAAAAXNSR0IArs4c6QAA\r\nABxpRE9UAAAAAgAAAAAAAABQAAAAKAAAAFAAAABQAABWL3xrAqoAAEAASURBVHgB\r\nlL2Fe1t7mueZme6uewNGMUu2LNkyySSjDJKZmZkSO8zM7CTmmJnZYbxUVbdgsKp7\r\nqqdrdp I cant post...

Grails validation over own domain

hibernate,grails,grails-domain-class,grails-controller,grails-validation
I'm using Grails 2.4.2 and have a class Contract which has many InvoiceRecipient's. The InvoiceRecipients class has an attribute invoiceType which has 2 possible values, 'O' for the invoice-original and 'C' for an invoice-copy. As you could imagine, only one record with type 'O' is allowed for the InvoiceRecipients for...

NullPointerException when publishing a Grails 3 plugin

grails
I'm trying to publish this Grails 3 plugin to Bintray, by following the steps in this guide. The final step is to run gradle bintrayUpload on the command-line from the project root dir. When I do this, I get the following error message FAILURE: Build failed with an exception. *...

Spock @Unroll annotation

grails,grails-2.0,spock
During a recent code review, the question came up regarding whether the @Unroll annotation belongs at the class level or the method level. The class in question requires @Unroll on most of its methods but not all of them. Does declaring @Unroll incur any performance penalties if declared at the...

Amazon Redshift: query execution hangs

grails,hadoop,amazon-web-services,amazon-redshift
I use amazon redshift and sometimes the query execution hangs without any error messages e.g. this query will execute: select extract(year from date), extract(week from date),count(*) from some_table where date>'2015-01-01 00:00:00' and date<'2015-12-31 23:59:59' group by extract(year from date), extract(week from date) and this not: select extract(year from date), extract(week...

Request via dynamic finders in Grails

grails,gorm
I've three domain classess: class Cafee { String cafeeName static hasMany = [halls: HallsZones] static constraints = { halls nullable: true } } class HallsZones { String hallName static scaffold = true static hasMany = [table : TablePlacesInfo] static belongsTo = [cafee : Cafee] static constraints = { table nullable:...

Intercepting login calls with Spring-Security-Rest plugin in Grails

rest,grails,spring-security
I am using the spring security rest plugin for Grails to provide a login mechanism for an AngularJS app. Login works fine, but I can't figure out how to intercept login calls, in order to store additional statistics on (invalid/valid) login attempts. As I am quite new to Spring Security...

Grails: Carry forward params on g:actionSubmit is clicked

grails,gsp
How to carry forward the parameters when g:actionSubmit button is clicked? Here is my gsp code: <g:checkBox name="msgCheck" checked="" value="${userInstance.emailId}"></g:checkBox> ... <g:actionSubmit class="update" action="delete" value="Delete" params="${params}"></g:actionSubmit> Here is my controller code: def delete() { try { def user_list = params.msgCheck //deleting the user //successful. redirect(action: "list", params: params) } catch...

Render a controller into a String

grails,grails-2.0
I can render a template or a view into a String, but how can I render a controller into a String ? I would like to perform this kind of operation: def myAction = { ... def html = renderToString(controller: 'myController', action: 'myAction', params: [what:'ever']) render modify(html) ... } ...

Send multiple ajax data from dynamically generated fields

jquery,ajax,loops,grails
How can I send multiple data from dynamically generated fields in ajax? Since I can't know the number of fields in advance I used a for loop which doesn't work for me. $.ajax({ type: 'GET', data:{ expectationPercentagePairId: JSON.stringify(expectationPercentagePairIds), expectationScores: expectationScores, for(var id in expectationPercentagePairIds){ score-${id}: $("input[name='score-'+id]") } }, url:'${g.createLink( controller:'review',...

How to use i18n with a Grails radioGroup?

grails,radio-button,gsp
How does the message needs to be set in messages.properties to get the label translated? (I'm on Grails 2.4.4) Domain: int handledBy messages.properties: Case.handledBy.1=Handled by A Case.handledBy.2=Handled by B``` View: <g:radioGroup name="handledBy" values="[1,2]"> <tr class="prop"> <td valign="top" class="name"> <label><g:message code="${it.label}" />:</label> </td> <td valign="top" class="value ${hasErrors(bean:CaseInstance,field:'handledBy','errors')}"> ${it.radio} </td> </tr>...

Grails: Carry forward params on hyperlink is clicked

grails,redirect,controller
How to carry forward the parameters when hyperlink is clicked? Here is my gsp code: <g:link class="grid_link" controller="user" action="delete" id="${userInstance.id}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure, want to delete?')}');">Delete</g:link> Here is my controller code: def delete() { try { def userInstance = User.get(params.id) //deleting the user //successful. redirect(action: "list",...

Fowarding from Apache to Tomcat breaks Grails rest api calls

apache,rest,tomcat,grails
Here is my setup: Apache virtual host listens on port 80, redirects to Tomcat at localhost:8080/webapp. Here is my virtual host settings: <VirtualHost xxx> ServerAdmin xxx DocumentRoot "xxx" ServerName xxx ProxyRequests Off ProxyPass /webapp http://localhost:8080/webapp ProxyPassReverse /webapp http://localhost:8080/webapp RedirectMatch (.*) xxx/webapp <Location "/"> # Configurations specific to this location. Add...

Retrieving data using Grails Domain returns with a Class Key by default

grails,gorm
I'm working with a Grails query service and I'm using these the code blocks to retrieve database rows via a domain class. adjustmentCodeList = AdjustmentCode.findAll { or { ilike('description', "%$filterText%") like('id', "%$filterText%") } } adjustmentCodeList = AdjustmentCode.list() adjustmentCodeList = AdjustmentCode.list(max: count, offset: from) It works fine actually, but there is...

Why does the Spring Social plugin occasionally return an empty email on the User class?

facebook,grails,spring-security,spring-social
I have a Grails project (v2.4.2) that is making use of the spring-security-facebook:0.17 plugin to authenticate via Spring Security. At first sight, all seems well. However, there is a large set of users that for some unknown reason I cannot access their email address. I am using spring social to...

Where to edit grails startup command line in IntelliJ IDEA?

grails,intellij-idea
Grails-2.5.0 startup fails if fork mode is disabled. I've found a workaround at https://jira.grails.org/browse/GRAILS-12129, which says; Don't use the spring loaded java agent. Removing the following from the command started by IntelliJ is enough But I cannot find where the command is written. Run -> Edit Configurations doesn't have any...

Grails: Intercept form request

grails
My Grails domain model consists of something like the following: Competition - with name String property Club - with name String property Team - with club and competition properties Game - with teamOne and teamTwo properties I'm looking to create a Game form that contains the following: a competition drop-down...

Update Joda-Time in Grails

grails,jodatime,localtime
I use Joda-Time via joda-time plugin in Grails to input time data, but its constructor shows time, which is one hour ahead then in my time zone. Compulsory timezone setting in constructor as like: new LocalTime(DateTimeZone.forID("Europe/Moscow")) doesn't help. I've heard, what it happens, because I've outdated timezone data containing old...

Using like to non-string columns in Grails

hibernate,grails,gorm
I'm currenty working on a Grails query service that involves retrieving row/s from the database with a specific criteria called filterText. List getAdjustmentCodes(params) { def filterText = params.filterText . . . adjustmentCodeList = AdjustmentCode.findAll{ or { ilike('description', "%$filterText%") // ilike('id', "%$filterText%") } } return adjustmentCodeList } Notice that I've comment...

GSP in plain Spring MVC - AST Transformation is not applied to taglib

spring-mvc,grails,gsp
I am trying to run GSP views in simple Spring MVC application (without Spring Boot). I am trying to duplicate the example located here: https://github.com/grails/grails-boot/tree/master/sample-apps/gsp but I am trying to run it in plain Spring MVC environment. I have successfully reached the phase when GSP pages are rendered, some g:...

grails create a list with like query from parent and child domain

grails,gorm,grails-domain-class
I am using grails 2.4.2. I need to create a list based on like keyword of query. Suppose this is an example >> def results = c.list(max: iDisplayLength, offset: iDisplayStart) { and { // eq("activeStatus", ActiveStatus.ACTIVE) } if (sSearch) { or { ilike('title', sSearch) ilike('shortDesc', sSearch) } } } Here,...