gsp

GSP rendering issue after server is idle overnight

ぐ巨炮叔叔 提交于 2019-12-24 17:56:03
问题 I have been intermittently encountering a difficult to replicate issue now for a few weeks. It seems (ie I can't yet be sure) that if the Grails app is not touched overnight something is perhaps unloaded causing: GSP rendered with values such as: <meta http-equiv="org.apache.commons.lang.StringUtils@72cd722b" content="org.apache.commons.lang.StringUtils@4e520b18"> <link href="/appname/static/bundle-bundle_application_head.css" type="org.apache.commons.lang.StringUtils@31da0262" rel="org

Grails - how to access properties file from GSP

落爺英雄遲暮 提交于 2019-12-24 17:09:31
问题 I need to have access to my properties file from GSP file to get one of it's values. I tried to find example over the web, but I couldn't. This is a file which I created and not Grails. Thanks! 回答1: If the properties file is under grails-app/i18n/ (it can be your own properties file, doesn't have to be one of the default ones) then you can access property values from the property file in a GSP using the message tag. See http://grails.org/doc/latest/ref/Tags/message.html. 回答2: you can access

Grails controller values (map) to separate javascript file

自作多情 提交于 2019-12-24 15:48:01
问题 I have checked a lot of forums, but I haven't got my answer. So - I have a lot of JS code, so i keep it in separate .js file (not in .gsp view). But now I have problems of accessing controller mapped values - I need them at my JS page, so I could generate my game field (based on values, that controller gives. I have def createGame(long id) { //getting my game info object... [gameInfo:gameInfo] } And then I accessed them in view, like - ${gameInfo.playerName} etc. But how to get them to JS

Groovy:Xml: How to display Xml response in textarea of gsp page

孤街醉人 提交于 2019-12-24 05:57:56
问题 Have an Xml response stored in a string, i want to display it in a textarea in gsp page String responseXml = ""<Cars> <Car>benz</Car> <Car>audi</Car> <Car>bmw</Car> </Cars>"" in gsp page <g:textArea name="xml" value="${responseXml}" rows="20" cols="100"/> getting response in textarea as a single line of xml tags like this <Cars><Car>benz</Car><Car>audi</Car><Car>bmw</Car></Cars> but what i want is display xml tags in textarea like this <Cars> <Car>benz</Car> <Car>audi</Car> <Car>bmw</Car> <

Multiple <g:select> in one GSP and multiple params in HQL inside controller

放肆的年华 提交于 2019-12-24 04:44:30
问题 GSP <html> <head> <g:javascript src="jquery-1.10.2.min.js"/> <g:javascript src="prototype.js"/> </head> <body> <form> <g:select from="['AFFILIATES', 'SEO', 'SEM','DISPLAYADS']" name="mv" onchange="${remoteFunction( controller:'Pgtyp', action:'ajaxGetMv', params:'\'mv=\' + escape(this.value)', onSuccess: 'printpgtyp(data)')}" ></g:select> </form> <script> function printpgtyp(data) { console.log(data); } </script> </body> </html> CONTROLLER package marchmock2 import grails.converters.* import

Error 500: Error processing GroovyPageView: null

柔情痞子 提交于 2019-12-24 02:14:48
问题 I'm building a Grails/Groovy/GSP app. I'm used to seeing errors such as "Cannot get property 'id' on null object", or "no property named ...". But I'm not sure what "null" by itself means! Error 500: Error processing GroovyPageView: null Just "null". Now I understand that the full error stack is going to help, and I'm still studying it to understand the error. But I just wonder in general what type of error is just "null". One other thing I noticed is that for error messages regarding groovy

Grails - Testing for the first element in a set using gsp each

荒凉一梦 提交于 2019-12-23 18:46:39
问题 Does anyone know how to test for the first member and last member in a gsp loop? Here's my jsp code: <c:forEach items='${aSet}' var='elem' varStatus="loop"> <c:if test='${loop.first}'> <p>Display something</p> </c:if> </c:forEach> I know you can test for status in a g:each statement but that's just an integer. Is there anything to access the first and last element? If not, is there another way to do what I'm doing? Any help appreciated. 回答1: I'm not sure what the problem with <g:each status>

How to create GSP taglib without Grails

为君一笑 提交于 2019-12-22 10:58:13
问题 We can use GSP without Grails, just mapping servlet groovy.servlet.TemplateServlet . And what about TagLibs? Here are docs about using TagLibs with Grails - we should just add class to grails-app/taglib folder. Is it possible to create custom GSP tag without Grails? And if it possible, even more important question, how exactly can it be done? UPDATE: it looks like there is a separate Grails Plugin for it - https://github.com/houbie/gsp-taglib. So the question actually boils down to how we can

What does the question mark mean in GSP/Grails?

怎甘沉沦 提交于 2019-12-20 09:05:09
问题 I saw this in my generated GSP pages. What does the ? mean? <g:textField name="name" value="${phoneInstance?.name}" /> 回答1: It's the "Safe Navigation Operator", which is a Groovy feature that concisely avoids null pointer exceptions. See http://docs.groovy-lang.org/latest/html/documentation/index.html#_safe_navigation_operator In this case, if phoneInstance is null, then it doesn't try to get the name property and cause a NPE - it just sets the value of the field tag to null. 回答2: The ?

Recursion in GSP page

你。 提交于 2019-12-20 02:36:22
问题 I have a domain class Node { String nodeId String label Node parent } In the GSP page I want to start with the root and print all its children (note I have a reference to parent and not the child). Any idea how to do this ? I am sorry but I am new and really confused. I want to print everything going down from root(not root) and root has no parent(its null). So i have written <g:each in="${nodes}" var="node"> <g:if test="${node.parent!=null}"> ${node.label} <g:render template="node" model="