Questions tagged [gsp]

Groovy Server Pages (GSP) is a presentation language for web applications, similar to JSP. GSP allows static and dynamic content to be mixed in the same document. The result is a dynamically generated HTML, XML or other type of document in response to a Web client request.

Groovy Server Pages (GSP) is a view technology which can be used for designing web application using Grails Framework. Developing GSP are very much similar to that of designing web pages with Active Server Pages (ASP) and Java Server Pages (JSP) but coding is very much simpler and easier than both of them. Users are provided with facility of having static, dynamic as well as mix of both contents at a time in a single application.

The output can be dynamically rendered to different forms like : HTML, XML, text and any other format based on Web client request object.If you are beginner in learning groovy, please read Introduction to Groovy – Scripting Language.

Advantages of using GSP using Grails

  1. A GSP uses Groovy GString for evaluation of expression generally using ${….} but whereas in JSP EL expressions are used for the same purpose but they are restricted only to object navigation to overcome this disadvantage JSTL functions can to be written for creating static helper methods, registering them through a taglib descriptor, adding a taglib declaration and finally implementing them using the function.
  2. A developer has been provided with Logical and Iterative tags in GSP with safe navigation operator and Elvis operator which can be implemented easily to fetch the needed results according to their requirement. For example these operators can be implemented in this manner: Safe navigation operator :${book.pages?.no()}
  3. Elvis operator : ${totalpages ?: 100}
  4. A GSPhas ability for invoking methods through Grails dynamic tags which makes it easier to produce well-formed markup:
<!-- With a regular tag -->
<a href="<g:createLink action="list" />">Click here</a>
<!-- As a method call -->
<a href="${createLink(action:'list')}">Click here</a>
  1. Creating and testing custom tag libraries using GSP are very easier then JSP since there is no need for developer to code tld files and taglib declarations.
1323 questions
8
votes
2 answers

adding id field to HTML end result of a GSP tag

Im creating a GSP form that i wish to submit using the $.ajax() call. I understand that the GSPs get rendered into the final HTML that is seen by the browser, and thus javascript can call normal HTML elements. my form is created as such:
Dave Anderson
  • 725
  • 3
  • 9
  • 17
8
votes
3 answers

Show enum values on GSP page and then bind them in the database

I have a use case in which I need to first show the value of enum on the GSP page first as a drop down list, have the user select one of those values and then finally bind the data to the domain. So my code on GSP looks like my enum is…
Nikhil Sharma
  • 2,221
  • 6
  • 25
  • 31
8
votes
3 answers

how can i render to the gsp view of other controller?

I m new to grails,just started with a small application, I'm searching a solution for below problem, Can any one tell me how can i render to GSP view page of other controller from current controller view page. With advance Thanks, Laxmi.P
Nandita
  • 307
  • 1
  • 6
  • 11
8
votes
1 answer

How to externalize GSP mail templates with Grails?

When emails are rendered from templates, the templates are looked up in "grails_app/views": mailService.sendMail { from sender to recepient.email subject "Don't forget" body (view: "/emails/reminder", model:[recepient:…
deamon
  • 89,107
  • 111
  • 320
  • 448
8
votes
1 answer

Grails: use controller from index.gsp

i am new to grails and i want to use a method from a specific controller in my index.gsp In Index.gsp i tried

${c.name}

but it says that the property is not available. MyController…
elCapitano
  • 1,821
  • 3
  • 22
  • 42
8
votes
3 answers

Dreamweaver + Grails

Has anybody tried doing GSP design with Adobe Dreamweaver CS4? It has support for JSPs, but it doesn't recognize the gsp extension, and even if it did I think there would be problems regarding the gsp tags that it would not recognize. I found a…
Chris King
  • 942
  • 2
  • 10
  • 14
8
votes
6 answers

Rendering HTML files in Grails

I've looked around but could not find a way of simply including or rendering *.html files in Grails. My application needs to g.render or templates which are delivered as html files. For this, as we know, html files have to be converted to…
sector7
  • 475
  • 1
  • 5
  • 9
8
votes
1 answer

Why does grails add a hidden checkbox to a form - and what does it do with it?

I have a checkbox on my GSP page as follows (which was stolen directly from the scaffolded "create" code for my domain object)...
8
votes
1 answer

Grails RadioGroup, how to bind labels to radio name

I'm struggling arround with the g:radioGroup tag -- I want to create some radios and some labels correspondig to the radios:
john Smith
  • 17,409
  • 11
  • 76
  • 117
8
votes
3 answers

Grails g:select no selection

I have the following combobox:
drago
  • 1,207
  • 4
  • 24
  • 45
7
votes
3 answers

Grails GSP Compilation?

When you compile a grails war, I understand that the .groovy code is compiled in to bytecode class files, but I don't understand how the container (say, tomcat), knows how to compile the GSPs when they are requested. Do the containers understand…
skaz
  • 21,962
  • 20
  • 69
  • 98
7
votes
1 answer

Grails: Getting current View name from within a Taglib

Is there any way to find out the current view (or gsp file) that is being evaluated? RequestURI doesn't work due to URL Mappings and forwards. I'm trying to retrieve resources dynamically based on the current GSP file. For example, if…
Reverend Gonzo
  • 39,701
  • 6
  • 59
  • 77
7
votes
5 answers

Slow Dynamic GSP Reloading in Production on AIX

We are using Grails 2.2.4, WebSphere 8.0.0.5 all running on AIX 6.1.0.0. Websphere is using the IBM JDK: Java(TM) SE Runtime Environment (build pap6460_26sr3ifix-20121005_02(SR3+IV27268+IV27928+IV28217+IV25699)) IBM J9 VM (build 2.6, JRE 1.6.0 AIX…
Alex Beardsley
  • 20,988
  • 15
  • 52
  • 67
7
votes
2 answers

Grails -Gsp - How to make Check-box checked based on the value of the field

I have a attribute called status in my domain which is String type can have any one of two values Applied , NotApplied I have two check boxes to input this value. in my edit page i want to display these two check box. If the value of status is…
maaz
  • 3,534
  • 19
  • 61
  • 100
6
votes
3 answers

How to call an action without generating a view in grails

How can I call a method in one of my controller classes without grails trying to generate a view?
Orca Ninja
  • 823
  • 1
  • 15
  • 29
1 2
3
88 89