w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » GRAILS » Page 1
Shared Java Classes on Cloud
I think you want to make classes available on remote sites. I have detailed how this can work for another question. I think you problem is the same, if not, please comment and I will adapt the answer

Categories : Grails

Grails' respond method outputs HTML content with charset=ISO-8859-1
It would seem this is a Grails bug, I've narrowed down the specific case when it happens: you need to have a static responseFormats = ['html', ...] limitation on the controller to trigger it. The fact that Grails' generate-restful-controller includes the responseFormats block automatically makes developers even more likely to encounter this issue. I've filed a bug report. EDIT: to keep the respo

Categories : Grails

Saving data by grails domain without id
You need to override Hibernate's default identity generator - here is the relevant chapter in the Grails documentation which basically points you to Hibernate documentation. From what I gather you would need to implement a custom IdentifierGenerator similarly to how this person did it for their project. I don't know why you are trying to define your own IDs but perhaps the following simpler solu

Categories : Grails

how to get class from class-name
Yes, there is a method: Class.forName(<String>) that should do the job You need. Mind the fact that You have to pass fully qualified class name (with package). See the docs.

Categories : Grails

How To Get All Plugin Related JARs in Grails?
I could not find any form of command that did this, but it is quite simple to do with a few lines of shell code: you would need to do do grails war twice - once without the nojars When doing a full war after completed run this: unzip -l warname.war |grep jar|awk '{print $NF}' This will list all the jars which you could store into a variable or something for your next bit to generate what jar

Categories : Grails

Where does the Grails Spring Security plugin save currentUser in HttpSession
After HttpSession inspecting session.getAttributeNames(), i want to share my result : session.getAttribute('SPRING_SECURITY_CONTEXT').authentication.principal

Categories : Grails

How can I get objects based off of certain associations?
Are you looking for something like this?... def results = Scholarship.withCriteria { grades { // myId must be defined somewhere above... idEq myId } } EDIT A comment below adds to the original question and asks what if another relationship was expressed like this... class Scholarship { static hasMany = [grades:Grade,majors:Major] } The query I show above wou

Categories : Grails

How to setup service method caching in grails
This may not help, but if you upgrade the application to Grails 2.4.x you can use the @Memoize annotation. This will automagically cache the results of each method call based upon the arguments passed into it.

Categories : Grails

Grails service injection null when injected service has older grails version
I had this problem as well, and it didn't hit me until 2.4.4. I have a custom security plugin that depends on the Spring Security Plugin. In my plugin, I'm setting a custom user details service in doWithSpring. This definition looks like this: userDetailsService(UserService) { grailsApplication = ref('grailsApplication') errorService = ref('errorService') } I had refe

Categories : Grails

Grails findById( null ) returning "random" result
We don't really support passing null as an argument to a dynamic finder like that. Dynamic finders have explicit support for querying by null. Instead of DomainClass.findByName(null) you would call DomainClass.findByNameIsNull(). If you have a reference that may or may not be null, instead of passing that as an argument to a dynamic finder, the code can almost always be made cleaner by writing

Categories : Grails

Selection of template value dynamically in gsp in Grails
Are you generating multiple DOM elements with the same ID value (e.g. loca) in the final HTML? That is wrong and could indicate why your Javascript is not working as expected. Try prefixing your IDs, e.g. id="sdh-loca" in one template call and id="wdm-loca" in the other. Then modify your Javascript accordingly.

Categories : Grails

Handling form with repeatable inputs
I'm looking at this block where you are setting dataInputInstance.inputA to be a single value and not the entire list object. Is this what you intended? dataInputInstance.inputA = params.inputA[i].trim() dataInputInstance.inputB = params.inputB[i].trim() Could you post your view GSP code if this is not the cause? Need to see how are you reading the values from your view on validation failure.

Categories : Grails

grails helloworld application gives exception
Finally got the issue. Looks like there is problem with below proxy setting commands: http://grails.org/doc/latest/ref/Command%20Line/set-proxy.html grails add-proxy client --host=my_proxy_server --port=my_proxy_port --username=my_uname --password=my_pwd grails set-proxy client Though i use proper proxy details, it is inserting entries in 'C:Users.grailsProxySettings.groovy' file as shown below

Categories : Grails

Want to load custom per page resources dynamically if exists
If you are talking about dynamic loading of js files in your GSP view, you could check if the file exist, before loading it. Take a look at this answer.

Categories : Grails

Intellij IDEA 14 Errors with grails run-app
I had faced similar issue when unknowingly kept on hit next next in hurry. So, you probably mistakenly created a gradle project as shown in screenshot. And when you recreated the project created it as "Create project from existing source" which idea well knows as grails-app (default for idea). See if you can reproduce the error by re-importing the project using import project form external module

Categories : Grails

r:external added via taglib is not processed as link in grails gsp
The issue you are having here is that you aren't calling the other tag library correctly from yours. You are simply writing out text to the output stream. For example the following lines: def baseUri = grailsAttributes.getApplicationUri(request) writer << '<r:external uri="' writer << baseUri << (baseUri.endsWith('/') ? '' : '/') writer << css writer << '"

Categories : Grails

Changing the threshold for an appender in Grails
You seem to have a fundamental misunderstanding of log4j and logging. What you are asking to do can't be done and I will explain why. Logging is based on two concepts. Loggers and Appenders. Loggers, receive messages, inspect those messages and determine based on their configuration if the message should be sent along to the appender. Threshold is a property of the logger. Thus, when a message ar

Categories : Grails

How to properly use Grails Command Objects
I don't think you should use them in the Beneficary class, use them in BeneficaryController. Command objects give you a standardized way of encapsulating, converting and validating request parameters. As such the main use for them is in a controller, not a domain class which can already do most of a command object's functions natively. You could rewrite your command like this if you wanted to ac

Categories : Grails

Grails BootStrap issue
Using Holders to access redisService in CacheManager seems to be a better option: import grails.util.Holders class CacheManager { def redisService = Holders.applicationContext.getBean("redisService") (...) When your redisService in CacheManager becomes null? Is it when developing app with reloading classes? Or in 'normally' running app? The first case would be a good explanation on w

Categories : Grails

Detecting a closed connection
Check if the object holding the results of the connect() method is null. You can also wrap a try catch statement around the code that attempts the connection, and print out the exception if it fails so you know where/what happened.

Categories : Grails

Groovy shorthand if else operator
Sounds like a job for the Elvis Operator value="${item.sequence ?: 'new'}" This will return item.sequence as long as it is truthy. If item.sequence is falsy, then it will return the second expression.

Categories : Grails

Email not sent via Gmail - Username and Password not accepted
I followed these steps and i'm not getting any errors and working fine.. install the mail plugin for grails using the command grails install-plugin mail 1.0.7 open Config.groovy and append these lines grails { mail { host = "smtp.gmail.com" port = 465 username = "your gmail id" password = "your password" props =

Categories : Grails

Process huge amount of data with grails and gpars
Trying to wrap processing of each element to task seems not optimal. Standard way to make parallel processing is split whole task to appropriate number of sub-tasks. You are starting with selection of this number. For CPU-bound task you might create N=number-of-processors tasks. Then you split task to N sub-tasks. Like this: persons = Person.listOrderByAge(order: "asc") nThreads = Runtime.getRun

Categories : Grails

Using I18N messages in grails cucumber test
You can get ask the messageSource bean what the text is and then compare that to the result of the request. This can look like this (with responseData.errors.username being the result of the request (i.e. the When step): Then(~'^an error message is shown that the user name is already used$') {-> assert responseData.errors.username.contains (message ('user.username.unique')) } message is

Categories : Grails

Grails i18n: Organisation of local files?
You can have as many files containing messages as you want and use your preferred organizational structure. Name the file however you want (e.g. loginController.properties and append language name postfixes to translated versions the same way Grails does for the default file (e.g. loginController_de.properties). It doesn't seem like you can use subfolders, though - all files must be in /grails-a

Categories : Grails

Grails - service fetches old domain data
This is more of a question than an answer, but I don't have the 50 reputation to comment, so I'll post it here. My apologies for breach of etiquette. Take a look in DataSource.groovy at some hibernate caching options, what do you see for these values? cache.use_second_level_cache cache.use_query_cache The default for the first one is true, and the default for the second one is false. If the qu

Categories : Grails

When I run grails run-app command I get Caching deactivated failed to create cache
Delete those jar files; you may have 'fixed' this problem, but you really just hid a symptom and the problem still exists, and will resurface, likely the next time you add a plugin. Go ahead and delete the lib directory too - it will probably just continue to tempt you with its presence. It seems to me that the core problem is simple and clearly stated; Grails wasn't able to create C:/grails/2.3.

Categories : Grails

bullets not displayed on GSP page
The reason why the "bullets" aren't appearing is because your page is likely including a style sheet that overrides that default behavior. This is common if you are using the default layout and styles provided with Grails. Check the rendered HTML in your browser to identify what CSS is being included (or check your layout that your GSP is using).

Categories : Grails

Grails: Legacy DB - Record with composite Id won't update
I believe the GORM mapping DSL expects just one id definition. Try combining your two id lines into just this one: id generator: 'assigned', composite: ["name", "lastName"] Also, in addition to implementing Serializable, your domain class should override equals and hashCode, as described under "Composite Primary Keys" here: http://grails.org/doc/latest/guide/single.html#identity

Categories : Grails

HQL query joining two domains that know nothing about one another
Can you modify the domain class definition in grails for Position as such to let gorm know about the association? Position { static hasMany = [budgets:Budget, employees:Employee] } Then you can do and hql statment like such: from Budget b left join b.position p where p.employees is not empty

Categories : Grails

Grails : Adding data in a many-to-many relationship generate an error
The addToXXX and removeFromXXX dynamic methods are created from the key in the hasMany map; this is also the name of the Set or List that Grails adds to the class for you to hold the items. Prefix with addTo (or removeFrom) and capitalize the first letter - so for taxonGroups it would be addToTaxonGroups, not addToTaxonGroup. Likewise for behaviors it'd be addToBehaviors and removeFromBehaviors.

Categories : Grails

Incorrect tag found by Geb in Grails app</b></a></td></tr> <tr> <td style='padding:16px;border-bottom:2px solid #C2C2C2;' align=left valign=middle> <div ><blockquote>It should be to LinkPage1 and not at LinkPage1 here if you want to go to /person/page1.gsp. Have a look at the Book of Geb, the difference between at() and to() is described there.</blockquote> </div> <br><div class=country2 style="float:right;display:inline-block;padding-left:1px" align=right> <font size=2><b>Categories :</b> <a class=country1 href='/category/grails/5698/1'>Grails</a> </div> <br> </td> </tr> <tr> <td bgcolor=E7EBED style='padding:5px;' ><a href="/questions/26912781/how-change-theme-of-dijit-calendar-from-tundra-to-claro-"><b>How change theme of dijit.Calendar from tundra to claro?</b></a></td></tr> <tr> <td style='padding:16px;border-bottom:2px solid #C2C2C2;' align=left valign=middle> <div ><blockquote>i think you can achieve this by editing 'dojoroot/dijit/themes/tundra/Calendar.css' as its just a normal css file u can copy the attributes from 'dojoroot/dijit/themes/claro/Calendar.css' to 'dojoroot/dijit/themes/tundra/Calendar.css' , so u have changed the css properties of only Calendar rest remains the same.</blockquote> </div> <br><div class=country2 style="float:right;display:inline-block;padding-left:1px" align=right> <font size=2><b>Categories :</b> <a class=country1 href='/category/grails/5698/1'>Grails</a> </div> <br> </td> </tr> <tr> <td bgcolor=E7EBED style='padding:5px;' ><a href="/questions/26908515/grails-spring-security-core-allow-authentication-from-url"><b>Grails spring security core allow authentication from url</b></a></td></tr> <tr> <td style='padding:16px;border-bottom:2px solid #C2C2C2;' align=left valign=middle> <div ><blockquote>For APIs it's better to use a stateless token based authentication Take a look at http://grails.org/plugin/spring-security-rest - this plugin adds token-based auth to Spring Security Core, that's what you need</blockquote> </div> <br><div class=country2 style="float:right;display:inline-block;padding-left:1px" align=right> <font size=2><b>Categories :</b> <a class=country1 href='/category/grails/5698/1'>Grails</a> </div> <br> </td> </tr> <tr> <td bgcolor=E7EBED style='padding:5px;' ><a href="/questions/26898628/grails-application-that-copies-and-unzippes-files-from-remot"><b>Grails application that copies and unzippes files from remote server to another remote server using SSH</b></a></td></tr> <tr> <td style='padding:16px;border-bottom:2px solid #C2C2C2;' align=left valign=middle> <div ><blockquote>I've used JSch a lot for SCP file transfer and remote exec using SSH and works very well. You could use it directly like you would in a Java app, by adding a dependency for the jar in BuildConfig.groovy compile 'com.jcraft:jsch:0.1.51' but the most trivial Google search I could manage that included "Grails" and "SSH" tells me that there's this plugin which looks great, and this plugin which als</blockquote> </div> <br><div class=country2 style="float:right;display:inline-block;padding-left:1px" align=right> <font size=2><b>Categories :</b> <a class=country1 href='/category/grails/5698/1'>Grails</a> </div> <br> </td> </tr> <tr> <td bgcolor=E7EBED style='padding:5px;' ><a href="/questions/26891237/let-grails-generate-without-render-template"><b>let grails generate without render template</b></a></td></tr> <tr> <td style='padding:16px;border-bottom:2px solid #C2C2C2;' align=left valign=middle> <div ><blockquote>Use grails install-templates command so you will be able to modify edit.gsp to your liking. http://grails.org/doc/latest/ref/Command%20Line/install-templates.html After modifying the installed tempĺates all generate code will follow its rules.</blockquote> </div> <br><div class=country2 style="float:right;display:inline-block;padding-left:1px" align=right> <font size=2><b>Categories :</b> <a class=country1 href='/category/grails/5698/1'>Grails</a> </div> <br> </td> </tr> <tr> <td bgcolor=E7EBED style='padding:5px;' ><a href="/questions/26888686/grails-lazyclob-in-criteria-query"><b>Grails LazyClob in Criteria query</b></a></td></tr> <tr> <td style='padding:16px;border-bottom:2px solid #C2C2C2;' align=left valign=middle> <div ><blockquote>You probably can, but you'd need to access the underlying real clob and then use the database-specific syntax for working with clobs in queries. For an example of how to do this in Oracle, see this other StackOverflow question. It's going to tend to be very inefficient though, especially of the clobs are large - it's unlikely that there's going to be any indexing active, so it will have to scan th</blockquote> </div> <br><div class=country2 style="float:right;display:inline-block;padding-left:1px" align=right> <font size=2><b>Categories :</b> <a class=country1 href='/category/grails/5698/1'>Grails</a> </div> <br> </td> </tr> <tr> <td bgcolor=E7EBED style='padding:5px;' ><a href="/questions/26887039/grails-storing-date-in-mysql-db-loses-time-component"><b>Grails - storing Date in MySQL db loses time component</b></a></td></tr> <tr> <td style='padding:16px;border-bottom:2px solid #C2C2C2;' align=left valign=middle> <div ><blockquote>The answer, thank goodness, turned out to be coding error on my part rather than some weird MySQL/Grails bug. I was sure all along that that must be the case, but just couldn't see where it might be. But in the end I discovered the culprit buried in a 'postUpdate' event handler. I had 'copied' the 'issued' property to another date variable and later used clearTime() on that object, forgetting that</blockquote> </div> <br><div class=country2 style="float:right;display:inline-block;padding-left:1px" align=right> <font size=2><b>Categories :</b> <a class=country1 href='/category/grails/5698/1'>Grails</a> </div> <br> </td> </tr> <tr> <td bgcolor=E7EBED style='padding:5px;' ><a href="/questions/26884302/grails-spring-securiy-authentication-with-three-parameters"><b>Grails Spring securiy authentication with three parameters</b></a></td></tr> <tr> <td style='padding:16px;border-bottom:2px solid #C2C2C2;' align=left valign=middle> <div ><blockquote>I did a talk a while back about the inner workings of the Spring Security plugins, and one example I did was a custom login with a 3rd parameter. There are a few steps involved to support this, so check out the downloadable code from this blog post for the process. It's not difficult, but requires a custom Authentication class, and custom filter and authenticator. But they're all based on existing</blockquote> </div> <br><div class=country2 style="float:right;display:inline-block;padding-left:1px" align=right> <font size=2><b>Categories :</b> <a class=country1 href='/category/grails/5698/1'>Grails</a> </div> <br> </td> </tr> </table> <br><div dir=ltr> <div class="pagination"><ul class="pagation"><li class="current"><a href="/category/grails/5698/1"><span>1</span></a></li> <li><a href="/category/grails/5698/2"><span>2</span></a></li> <li><a href="/category/grails/5698/3"><span>3</span></a></li> <li><a href="/category/grails/5698/4"><span>4</span></a></li> <li><a href="/category/grails/5698/5"><span>5</span></a></li> <li class="nextpage"><a href="/category/grails/5698/2"><span>Next</span></a></li><li class="nextpage"><a href="/category/grails/5698/73"><span>»</span></a></li></ul></div><br></div> <!----------------------------------end body----------------------------------> </TD> <td bgcolor=ffffff width=250 align=center valign=top> <a href="http://w3hello.com/"><img src="/images/160-600.jpg"></a><br><br> </td> </TR> </table> <TABLE width=100% BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR> <TD align=center WIDTH=100% > <table bgcolor=ffffff width=990 cellpadding=0 cellspacing=0 border="0"><tr><td align=center width=990 height=25 > <img width=990 src="/images/bg-categories2.png"></td></tr></table> <TABLE dir=ltr width=990 CELLPADDING=0 CELLSPACING=0 > <tr> <td width=990 dir=ltr bgcolor=113660 height=5 align=center class=cb></td></tr> <tr> <td width=990 dir=ltr bgcolor=034B81 height=80 align=center class=cw> <div style="display:inline;float:left;padding-left:30px;"><font color=white> © Copyright 2018 <a href="http://w3hello.com" target=_blank>w3hello.com</a> Publishing Limited. All rights reserved. </font></div> <div style="display:inline;float:right;padding-right:30px;"><A href="/privacy-policy.php">Privacy Policy</A> - <A href="/copyrights.php">Copyrights</A> - <A href="/contact.php">Contact us</b></A> - </font></div> </td> </tr> </TABLE> </TD> </TR> </TABLE> </BODY> </HTML>