I'm just getting started with grails, and I'm having an issue.
I have a "controller" and "view" for the projects home page (there's no model for the home page)
I called the view "index.gsp", and put it in a directory views/home
However, no matter what I do, grails is trying to read the page "home.gsp" (and then home.jsp), despite me h...
I have a domain class in Grails with a field journeyDate. journeyDate is defined like this:-
Date journeyDate
then in my list.gsp I display the date like this:-
${fieldValue(bean:journeyInstance, field:'journeyDate')}
And it is displayed in the following format:-
2009-08-19 17:12:00.0
does anyone know how I can format this on the l...
I'm trying to use GSP outside grails and ran to my first problem.
I cannot seem to do a taglib import in my GSPs.
Given
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
When I run my app,
I am getting a
javax.servlet.ServletException: Creation of template failed: groovy.lang.GroovyRuntimeException: Failed to p...
If I leave grails.views.default.code='none' in the grails Config.groovy, it's up to me to HTML encode my expressions explicitly in the GSP files: ${myValue?.encodeAsHTML()}.
If I set grails.views.default.codec='html" in the Config.groovy, then the HTML encoding happens automatically for every expression: ${myValue}.
My question: If I s...
I am making modifications to /grails-app/views/index.gsp.
When I save the file and refresh http://localhost%3A8080/index.gsp in Firefox, I am getting an old version of the file.
Is there a way to prevent Grails from caching and rendering old versions of the file?
(I tried restarting the server and clearing Firefox's cache.)
Thanks!
...
How do i render a view in a portlet. Have an action that handles a form submit from a portlet view window.
def actionView = {
//TODO Define action phase
println "IN THE ACTION !!!!"
String name = portletRequest.getParameter("name")
if(name){
println "RESNDERING RESULT"
render(view:'result',m...
When running my Grails 1.1-M2 app as a WAR under Geronimo 2.1.4 (jetty6, javaee5), the HTML generated from the GSPs do not include my dynamic content.
Specifically, this GSP snippet:
<tr class="prop">
<td valign="top" class="name">
<label for="type">
<g:message code="album.type.label" default="Type" />
<...
In my Grails controller I'm responding to an AJAX call and using render to return the text:
def ajaxRandomPersonName = {
def person = get a random person ...
render "Name: ${person.name}"
}
The problem is that render renders the whole template. So instead of just rendering "Name: John" it renders all the icons, navigation, etc...
I have a g:select in my view that displays a list of products:
<g:form name="addproductform" action="saveProductToInventory" method="post">
<g:select from="${products}" name="product" value="${it?.id}" />
<g:hiddenField name="inventory.id" value="${inventoryInstance.id}" />
<input class="save" type="submit" value="Save produ...
I am using on my table to sort the values. but it is causing wrapping up the column header on firefox. Its work fine on IE.
can anyone suggest some solution for this?
using grails 1.0.1 version.
thanks
...
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 a...
Hi guys,
is there any possiblity to select a option field by default in gsp g:select tag?
I only saw the "noSelection" parameter in the documentation.
<g:select name="user.age" from="${18..65}" value="${age}"
noSelection="['':'-Choose your age-']"/>
But I need a default selection from the data I got.
For example 18..65 is my ...
I've tried with netbeans and eclipse, with no luck... (coudn't try IntelliJ idea)
I gave a quick look ant the code
http://kickjava.com/src/groovy/servlet/TemplateServlet.java.htm
and it gives me the impression that .gsp pages are translated to .groovy servlets (groovlets) in memory (I might be wrong)...
so perhaps it's not so easy to...
This works as expected in a GSP-page:
<td>${Foo.findAllByBar(bar)}</td>
But when adding a collect statement the code breaks ..
<td>${Foo.findAllByBar(bar).collect { it.name }}</td>
with
Error 500: Could not parse script [...gsp]: startup failed,
...: 129: expecting '}', found ')'
@ line 129, column 196. 1 error`.
I wa...
In Grails, there are two mechanisms for modularity in the view layers : template and taglib.
While I am writing my own Grail app, I am often facing the same question when I need to write an UI component : do I need to use a template or a tagLib ?After searching the web, I didn't find a lot of best practices or rules of thumb concerning ...
The Grails Config.groovy setting grails.views.default.codec specifies the default codec used to encode data within ${...} in Grails views.
This config setting can take any of the values none (no filtering required), html (to avoid XSS-attacks) and base64 (has no real-world use-case that I know of).
The Grails default is none (no filter...
With tags, you can do this in a gsp:
<g:if test="${someBean?.aCondition}">
<div class="aSection">
...
</div>
</g:if>
What I really want to do is add a second 'class' that either contains the 'display:none' or 'display:block' attributes based the value of '${someBean?.aCondition}'.
The final html would like this:
<div class="aS...
Hello,
is there a way to use groovy builders to build JSP files in a Grails application keeping things enough integrated?
To explain better: by default Grails uses gsp files that are nice but quite verbose..
<div class="clear">
<ul id="nav">
<li><g:link controller="snippets" action="list">Snippets</g:link></li>
<li><g:link ...
Using Grails' GSP <g:set> tag, is it possible to specify the type of the variable? I want to declare an integer variable, but <g:set> always declares a sting. For example:
<g:set var="x" value="100"/>
${x.getClass()}
${x+23}
results in
class java.lang.String
10023
I'd like to declare x as an integer. I noticed that using the JSP ta...
In my Grails GSP file I'm using the HTML meta tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
The problem is that Grails closes this tag and renders it as:
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
This fails W3C's HTML validation (since my doctype is HTML and not XHTML).
Is there...