gsp

I can't get the grails controller "render" method to work with an explicit template

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...

formatting dates in Grails

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...

GSP taglib import

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...

Overriding grails.views.default.codec='html' config back to 'none'

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...

How to prevent Grails from caching old versions of gsp file?

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 to render a view a grails portlet

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...

Grails GSP doesn't generate intended HTML under Geronimo

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" /> <...

Grails "render" renders the template

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...

How to configure and retrieve the value from a g:select in Grails?

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...

<g:SortableColumn > tag shows different behavior on Firefox browser.

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 ...

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

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...

GSP g:select option default selection

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 ...

how to debug a gsp page? (no grails, just gsp)

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...

Why doesn't .collect() work in the following GString?

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...

Grails: Templates vs TagLibs.

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 ...

Why doesn't grails.views.default.codec default to "html"?

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...

Adding a class to html element conditionally with grails tags

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...

Using HTML builders in grails instead of GSP

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 ...

Grails GSP <g:set> tag set as integer?

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...

Grails interprets and closes HTML meta tag

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...