grails-2.0

How to include jquery.js in Grails?

ⅰ亾dé卋堺 提交于 2019-12-20 12:07:09
问题 I have a Grails 2.0.0 project that was created using grails create-app . In my HTML and GSP files, I'm trying to include jquery.js . I've tried all of the following without success: <script type="text/javascript" src="jquery/jquery-1.7.1.js"></script> <script type="text/javascript" src="jquery/jquery.js"></script> <g:javascript library="jquery"/> The first two <script> tags results in 404 Not Found (verified with Firebug). The <g:javascript> tag results in nothing being included (verified

How to make Grails get latest local jars from Maven repository?

纵饮孤独 提交于 2019-12-19 19:44:31
问题 In my Maven repo (.m2). there is one my local jar like sub_app-0.1.jar. I have same copy of the it in ivy-cache. I run maven install on sub_app then new sub_app-0.1.jar file created. After, I run grails clean and it not getting my new sub_app-0.1.jar from .m2. But, if I remove (delete) sub_app-0.1.jar file from ivy-cache and run the grails clean then it is getting new sub_app-0.1.jar file into ivy-cache. If I change the version in sub-app pom and grails pom and Grails is taking latest one.

How to get current_user by using Spring Security Grails plugin in GSP

痞子三分冷 提交于 2019-12-19 08:13:28
问题 I am newbie in Grails. I am using Spring Security Grails plugin for Authentication purpose. I want to get current user in my view gsp file. I am trying like this ... <g:if test="${post.author == Person.get(springSecurityService.principal.id).id }"> <g:link controller="post" action="edit" id="${post.id}"> Edit this post </g:link> </g:if> Here I want to show Edit this post link to only those posts who created by signed_in user. But It showing ERROR - Error 500: Internal Server Error URI

Grails Send Mail is not working

戏子无情 提交于 2019-12-18 09:45:19
问题 I am using Mail Plugin to send email in my grails application. I am doing like this ... Config.groovy ---- grails { mail { host = "smtp.gmail.com" port = 465 username = "example@gmail.com" password = "*********" props = ["mail.smtp.auth":"true", "mail.smtp.socketFactory.port":"465", "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory", "mail.smtp.socketFactory.fallback":"false"] } } and Controller --- class MailController { def mailService def sendmail = { mailService.sendMail {

Grails spring security fails to present the login page due to a redirect loop

血红的双手。 提交于 2019-12-18 09:34:40
问题 I have upgraded my current spring security plugins to spring-security-core-2.0-RC2 spring-security-ui-1.0-RC1 PROBLEM and I noticed that my login screen no longer shows up. In Chrome it says This page has a redirect loop STEPS TO RECREATE THE PROBLEM So I have tried to create a brand new application called Test to try to isolate the problem. First, I installed the security and security-ui plugins by adding the following entries in the BuildConfig.groovy : compile ":spring-security-core:2.0

Image byte [] to response.outputStream in Grails leads to “Cannot forward after response has been committed”

独自空忆成欢 提交于 2019-12-18 09:16:14
问题 In my Grails controller I have an image as byte []. I want to write this byte [] directly to the response.outputStream I use the following code to do that: def getImage() { def attachment = Attachment.get(params.id) def imageByteArray = // some byte image from attachment (is a jpg image) withCacheHeaders { etag { if (imageByteArray) "${imageByteArray}".encodeAsSHA1() else "${new Date()}".encodeAsSHA1() } delegate.lastModified { if(imageByteArray) { attachment.lastUpdated ?: 0 } } generate {

How to unit or integration test use of injected messageSource for i18n in Grails 2.0 service

北城余情 提交于 2019-12-18 03:17:10
问题 I make use of a message bundle in one of my services in a Grails 2.0 project for internationalized text. The use case is an email subject that is sent via the mail plugin in an asynchronous way, so it really doesn't make sense to have this in a controller or TagLib (given the usual argument of not accessing your text or views in a service). This code works fine in my running Grails app, but I'm not sure how to test it. I tried a PluginAwareResourceBundleMessageSource in my defineBeans as that

How to show flash.message in Grails after AJAX call

耗尽温柔 提交于 2019-12-14 02:05:40
问题 I want to show some flash message after completion of AJAX call. I am doing like this .. Controller Action -- def subscribe() { def subscribe = new Subscriber() subscribe.email = params.subscribe if (subscribe.save()) { flash.message = "Thanks for your subscribtion" } } View Part -- Subscribe : <g:formRemote onSuccess="document.getElementById('subscribeField').value='';" url="[controller: 'TekEvent', action: 'subscribe']" update="confirm" name="updateForm"> <g:textField name="subscribe"

Unit testing a domain with transient property

拟墨画扇 提交于 2019-12-13 19:16:16
问题 I am trying to unit test a controller for User domain generated by Spring Security Core Plugin. The controller was generated with grails generate-all. The domain has a transient property called springSecurityService. In my unit test I am trying to mock that service and assign this transient variable to my mocked version. However, I get this error : No such property: springSecurityService for class: com.myapp.security.SecUser Possible solutions: springSecurityService groovy.lang

Grails Cache resources not working

时间秒杀一切 提交于 2019-12-13 13:35:57
问题 Please give some suggestions... Cache resources not working now just few days back it working. Same code same plugins, i found one deference compare to previous(while it working fine) , while shutdown the tomcat server. It is not shutting down itself, and giving some information in console like this: INFO: SessionListener: contextDestroyed() Apr 16, 2013 6:41:19 AM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextDestroyed() Apr 16, 2013 6:41:19 AM org.apache