Menu
  • HOME
  • TAGS

Grails Url shortener plugin not getting installed

grails,grails-plugin,grails-2.0,url-shortener

The default grails repo provided in 2.2 or smaller does not work now. We fixed this issue by adding the following line to the grails.project.dependency.resolution closure in the BuildConfig.groovy file: grails.project.dependency.resolution = { repositories { ******** mavenRepo "http://repo.grails.org/grails/repo/" ******** } } *duplicate answer of Scott's answer...

Date picker in Grails with JQuery UI: Resource not found error

grails,grails-2.0,grails-plugin

without attempting the defaults you are attempting to override your jquery-ui. My recommendation is to try out the defaults and progress from there: as per instructions: http://grails.org/plugin/jquery-ui Install jquery-ui by adding compile ":jquery-ui:1.10.3" to your BuildConfig refresh-dependencies Then add this to your main.gsp <r:require module="jquery-ui"/> see how that goes then...

How to tell a Grails plugin to use a secondary datasource (not the default one)?

grails,grails-plugin,grails-2.0

In Domain Classes of your plugin you have to do something like this static mapping ={ //if you need to use the second ds only in Production you can use the Environment if(Environment.PRODUCTION){ datasource('your_sencondary_datasource') } } and in your principal application in your Datasource.groovy you need to map your datasource...

Grails getter writing to database?

grails,gorm,grails-2.0

All fields are persisted to the database unless you explicitly define otherwise. The fact you are overriding a getter doesn't automatically tell Grails that you do not want to persist that property to the database. To do that you must define the property as transient: static transients = ['status'] ...

Why do we need explicit relationships in grails?

grails,gorm,grails-2.0

Everything you defined there should work fine. You don't have to use any of the other stuff that you mentioned that GORM offers, but there are reasons that you might want to. For example, you can write a class like this: class Author{ Set<Book> books } That is not the...

How to set formula in grails domain class?

grails,gorm,grails-2.0,grails-domain-class,grails-services

You need to make these fields non transient to use in criteria. See reference document http://www.grails.org/doc/latest/guide/GORM.html#5.5.2.11%20Derived%20Properties...

controller logic for gsp templates

grails,grails-2.0,gsp

The proper way to reuse your template (as you have defined here) is to actually include the call to the owning controller from your other GSP. Such as: <g:include controller="myFancyControllerName" action="actionThatRendersTemplate" /> In doing so you are ensuring that the logic that builds the model used by the template is...

Grails: What is the difference between using actionName and pageScope.actionName inside taglibs?

grails,grails-2.0,gsp,taglib,grails-controller

pageScope. As for the usage in your company code, I guess it depends on how long ago it was written. Referring to docs in 2010 like: grails_pagescope_variable_in_gsps_and_taglibraries and overriding-plugin-templates-in-grails-application there are a few more around people were using it then, can't comment on if it was essential back then.

Testing a service in a domain class

unit-testing,grails,grails-2.0

Generally speaking, Service classes should be mocked when called from other classes for Unit Tests, otherwise, you'd want to write an Integration test. Personally, if that is all your service is doing I'd just make that a method on the domain itself: class Vendor { def sponsorService SponsorLevel getSponsorLevel(){ BigDecimal...

How I can configure xmpp server with my Grails application?

grails,xmpp,chat,grails-2.0,agsxmpp

You can use Spring Integration and let it deal with the xmmp connection. It's pretty simple to connect to a xmpp server and read and write messages. With Spring Integration your code is totally agnostic of the xmmp server. Regards, Iván....

Failing to save during Test on Controller

unit-testing,grails,testing,grails-2.0,spock

I don't believe testing a controller should cover the service logic. I'd mock the service, if I were to write a unit test for a controller, and test the service separately in its own unit/integration tests. For example: /* * in controller spec */ def setup() { def serviceMock =...

How to show parent domain field in select box in grails

grails,gorm,grails-2.0,grails-domain-class,grails-controller

You can construct the drop down list on Service/Controller and pass via modal to gsp page and use. The controller/service method will look like: def c = AdtAuditorSchdlPack .createCriteria() def results = c.list() { and{ // your criteria logic } order('id', 'asc') } Construct the list based on your logic:...

Grails 2.4.4 unable to create codecLookup bean

grails,grails-2.0

I got to the bottom of this. I had an abstract base codec defined in grails-app/utils along with a couple of sub classes i.e grails-app/utils/ BaseCodec.groovy MyCodec.groovy abstract class BaseCodec { ... } class MyCodec extends BaseCodec { ... } In 2.3+ this worked however in 2.4 grails doesn't like...

Spock @Unroll annotation

grails,grails-2.0,spock

The @Unroll annotation is intended to be used on the method level. But it can also be used on the class level as indicated in the Unroll.java JavaDoc comments: The {@code Unroll} annotation can also be put on a spec class. This has the same effect as putting it on...

Grails 2.3.4 on heroku - BeanCreationException

grails,heroku,grails-2.0

I have tried to reproduce the issue but the exception I get is different. Try following steps may be your issue resolved: BuildConfig compile ":mail:1.0.5" Config grails { mail { host = "smtp.gmail.com" port = 465 username = EMAIL_ADDRESS password = PASSWORD props = ["mail.smtp.auth": "true", "mail.smtp.socketFactory.port": "465", "mail.smtp.socketFactory.class": "javax.net.ssl.SSLSocketFactory",...

How to set Response Headers with Grails CacheHeaders Plugin?

html,grails,groovy,httprequest,grails-2.0

The reason why these headers do not get set is by design. Not design of the plugin but HTTP. According to RFC2616 content-type and content-length headers should not be sent with HTTP response status of 304.

Grails 2.4.4 DataSource “create-drop” fails to drop all tables having FKs

mysql,grails,grails-2.0,hibernate-4.x

For my case setting FK-checks to 0 for MySQL (v5.5.25) solved this, although I am not entirely sure if I am supposed to SET FOREIGN_KEY_CHECKS=0 at all. If anyone has a better solution, please do share. EDIT The problem was faced due to this. Lesson learnt - Thou shalt not...

grails render a list in select after ajax call by remote function

grails,grails-2.0

Your controller might be look like as below, def loadThanaByDistrict(){ def district = District.get(params.districtId?.toLong()) def thana = Thana.createCriteria().list{eq('district',district)} String options thana.each{ options += "<option value='"+[replace it with your expected field]+"'>"+[replace it with your expected field]+"</option>" render options } I hope it'll work fine....

Using the Shortcut to Redirect in a Controller

grails,grails-2.0

Since Grails 2.3, redirect can be done in UrlMappings as below: "/someAction"(redirect : [controller: 'home', action: 'index']) Refer this for alternative ways. UPDATE: In order to use the mapping from controller a better alternative would be to use namedMappings: // UrlMappings static mappings = { name handle404: "404" { controller...

How modify value of attributes passed into Grails GSP

grails,grails-2.0

You should be able to do something like this (even though it is dicouraged and your controller should handle this) at #1 <g:each in="${locns}" status="i" var="locn"> <% def locnChanged = new ArrayList<>() %> <% def x = locn %> <% x.locn = locn.addr.replace("V", "X") %> <% locnChanged.add(x) %> </g:each> at...

Grails: g:link not applying params with dynamic keys

grails,grails-2.0

It seems that it may be this bug: GRAILS-9774 - the value is lost if key in params map is of type GString. Converting the key to String should resolve your problem: <g:link action="${nextDashboardUriMap.nextAction}" params="${[("$nextDashboardUriMap.queryStringId".toString()): "$entityId" ]}"> (...) ...

How to set remember me always true or loggedin in grails?

grails,spring-security,grails-2.0

<input name="_spring_security_remember_me" type="hidden" value="true"/> have you tried with an actual check box ? you could even default it to be checked ...

Use the logger in grails 2.3.4

grails,logging,grails-2.0

info 'grails.app' sets the info logging level for all classes that are in grails-app folder - like controllers, services, domain classes, taglibs etc. If you want to set the info level for ALL classes, even third-party dependencies, you should set the root logger to this level: import org.apache.log4j.Level ......

Grails bootstrap hidden-print not working as expected

css,grails,twitter-bootstrap-3,grails-2.0,grails-plugin

The issue is that the CSS isn't being included when the media type is print. <link href="/SomeProject/static/bundle-bundle_bootstrap_head.css" type="text/css" rel="stylesheet" media="screen, projection"> That only includes the CSS for screen and projection. Regarding your comment: I'm very sure that if the media attribute on the link element doesn't include print then the...

Collection (as opposed to member) endpoint in Grails REST?

rest,grails,routes,grails-2.0

It was simpler than I thought though if there's a more canonical way of solving this I'd appreciate the feedback. Basically I defined the collection endpoint before the resource endpoint. class UrlMappings { static mappings = { "/books/total_count" (controller: "Book", action: "totalCount", method: "GET") "/books" (resources: "Book") } } So...

Grails (iOS specific): Returning video (mp4) file gives Broken Pipe exception (getOutputStream() has already been called for this response)

ios,grails,grails-2.0

This turned out to be an iOS specific issue. The range header is required to be implemented, and if you try to return the entire file content for the response of a range request, iOS will not make additional requests. The following is the code I used: try { def...

Set property method in grails could not change the instance globally

grails,grails-2.0,grails-domain-class

At what point in your service are you checking the state of the instance in the database? When is your instance created? Your method sets the protect variable but doesn't save the instance. If you call save() then the instance isn't actually saved to the db, it's only saved to...

Decompression of GZIP:ed response (Grails / Groovy)

rest,groovy,gzip,grails-plugin,grails-2.0

Spring and HttpComponents will handle the decoding automatically: HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().build()); RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory); ResponseEntity<String> response = restTemplate.exchange( "some/url/", HttpMethod.GET, new HttpEntity<Object>(requestHeaders), String.class); ...

grails g:each tag is not showing anything in view

grails,grails-2.0

Try with this: Controller: def homePage() { def androidGameInstanceList = AndroidGameDist.listOrderByDownloadCount(order: 'desc',max: 10) androidGameInstanceList.each { println(it.downloadCount) } [androidGameInstanceList: androidGameInstanceList] } gsp: <g:each in="${androidGameInstanceList}" status="i" var="androidGameInstance"> <p>value : ${androidGameInstance.downloadCount}</p> </g:each> ...

how to set radio button for edit in grails

grails,grails-2.0,grails-domain-class

You may want to consider the radioGroup tag within Grails instead of manually authoring your radio buttons. However, if you decide to continue manually authoring your radio buttons you will need to account for selecting the current value. For example: <g:radio name="religion" value="muslim" checked="${radioButtonInstance?.religion.equals('muslim')}"/> In the above example you will...

Render a controller into a String

grails,grails-2.0

You can use grails include tag for this def html= g.include(controller: 'myController', action: 'myAction', params: [what:'ever']) ...

Assign foreign key value in grails

grails,grails-2.0,grails-domain-class

That's because params.districtId is String and you are assigning it to the property of type District. So you have to retrieve an instance of District first, with id you can use this: thana.district = District.get(params.districtId?.toLong()) ...

Grails web-app image directory is not working properly in war

tomcat,grails,debian,grails-2.0

There is no need to config about folder in config.groovy. just follow the below code. at least worked for me ::: def gameImage = request.getFile('appImage') String imagePath = "${request.getRealPath('/')}/apps/gameImage/" new File( imagePath ).mkdirs() gameImage.transferTo( new File( imagePath + File.separatorChar + gameImageName) ) ...

Grails find by property

grails,grails-2.0

with grails 2.3.8 and H2 Employee.findAll("FROM Employee e WHERE :role in elements(e.roles) ", [role: Role.DFC.toString()]) this works… even if I think that Role could be a real Domain simplifying all operations...

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

grails,gorm,grails-2.0,grails-domain-class

Neither needs a call to save() in most contexts. What you're seeing in the "some examples" link is a save to the main domain object Author, which gets persisted first, and then the other properties will make it in the database with a proper id to link back to. For...

Put JavaScript at the Bottom with Grails Asset-Pipeline

javascript,grails,groovy,asset-pipeline,grails-2.0

I just add lines at the bottom of my .gsp or layout files: <asset:stylesheet src="xxx.css"/> <asset:javascript src="xxx.js"/> xxx.js and xxx.css can include a manifest to load more stuff. You would load JQuery via the manifest(s): xxx.js: //= require jquery //= require select2.min.js //= require_self ...

Render a GSP page to a file in a web-app subfolder

grails,grails-2.0,print-css

Okay, I think I understand what you're trying to do, and I'm going to try to explain in more detail what I've said in the comments. I'm not sure if this is the best approach for this, but it's what I would try given no other options. Requirement: Take the...

Prevent duplicate entry for save smartly in grails

grails,grails-2.0

This sounds like the prefect use case for the unique constraint. class MyDomain { String name OtherDomain related static constraints = { name unique: ['related'] // each instance must have a unique name per related } } Edit Updated based on question in comment. The above will ensure that name...

Why don't unflushed domain objects revert to their “saved” state after discard? Can I get the “clean” version?

grails,gorm,grails-2.0,grails-domain-class

Hibernate doesn't have a process for reverting state, although it seems like it could since it keeps a clean copy of the data for dirty checking. Calling the GORM discard() method calls a few layer methods along the way but the real work is done in Hibernate's SessionImpl.evict(Object) method, and...

Grails - Unit test controller that's using a named marshaller

grails,grails-2.0,spock

You can create the named config in the test itself. For example: given: 'register marshaller' JSON.createNamedConfig('complete') { it.registerObjectMarshaller(Map) { Map item -> item } } when: 'controller action is called' controller.userByEmail() then: // assertion goes here ...

How to delete a child domain row in grails

oracle,grails,gorm,grails-2.0,grails-domain-class

You should first remove the reference from parent and then delete the child e.g def entryMeetingDetailsDelete = AdtEntryMeetingDetails.get(Long.parseLong(params[entryMeetingDetailsId + detailsCounter])) adtEntryMeetingInstance.removeFromAdtEntryMeetingDetails(entryMeetingDetailsDelete) entryMeetingDetailsDelete.delete() ...

Grails scheduling a task without plugins

grails,scheduled-tasks,grails-2.0

After researching for quite some time we came to this conclusion: Within the Groovy Source Packages we created an interface interface Task{ void executeTask() } Next we created our Task: class SayHelloTask implements Task{ void executeTask(){ println "Hello" } } Within the resources.groovy file we added the following: import package.SayHelloTask...

How to limit the size of association in grails?

grails,gorm,grails-2.0

I think this should work: def results = Bid.withCriteria { order { eq 'id', 1 } projections { property 'order' } maxResults 10 } But please note that you have to change your Bid domain class to add the relation in the other way from Bid to Order: class Bid...

What is the minimum memory footprint for a simple grails application?

grails,heroku,grails-2.0

Currently the minimum for a basic application is around or just above the 512mb amount depending on what the app does. We are aware of the problems this creates for Heroku and currently you need double dynos to run Grails applications on Heroku. We are working to improve Grails support...

What are inline plugins?

grails,grails-plugin,grails-2.0

Inline plugins in Grails 2.x are outlined in the documentation section for plugins. From the documentation: An application can load plugins from anywhere on the file system, even if they have not been installed. Specify the location of the (unpacked) plugin in the application's grails-app/conf/BuildConfig.groovy file Creating an inline plugin...

How do I make Grails execute shell commands just before creating war file?

spring,grails,grails-2.0

To do something before the war is packaged, use the "CreateWarStart" event, e.g. as described in this answer. To actually run the Git command, use can use Groovy's ability to execute commands as strings, e.g. 'git pull origin master'.execute() (see the docs here) or do it more programmatically with ProcessBuilder...