gsp

How to pass a List of Maps to a GSP page view and iterate over it

北城以北 提交于 2019-12-11 19:26:41
问题 Let's say we want to show information about the files of a folder. We have to save the information of each file in a Map. Then, add these Maps to a List. Controller action: def show() { List results = new ArrayList(); File dir = getDir(params.id); if (dir.exists()) { dir.eachFile { Map fileInformation= new java.util.LinkedHashMap() fileInformation.put("name", it.getName()); fileInformation.put("size", it.length()); fileInformation.put("path", it.getAbsolutePath() ); results.add

using GSP tags from Javascript

限于喜欢 提交于 2019-12-11 17:12:10
问题 I am trying to create a dynamic HTML table using javascript. I have written a small function to add rows to the table on the fly. However the individual cells themselves should be gsp tag elemets. In the example below I am trying to use the autoComplete tag provided by the grails-UI plugin. Even though I set the innerHTML of the cell to the gsp tag, it is not being rendered on the page. function addIngredientRow(tableName,element){ var table = document.getElementById(tableName); var lastRow =

Grails hasErrors method with ternary operator?

▼魔方 西西 提交于 2019-12-11 13:36:41
问题 I'm developing application using Grails framework and I'm having problems with hasErrors when invoked as a method from a gsp view. I have a form that get's populated by values from a database (default values). Those values are stored in a session object. Users can edit values in form fields and send results back to the database. Before data gets persisted I have a command object that validates data. If there are errors command objects renders view with the same form and errors highlighted.

compare two html tables data line by line and highlight using jquery

为君一笑 提交于 2019-12-11 11:46:50
问题 I have created a GSP page with two dynamic table with data and now i have to compare the data (inner html) and if any difference then highlight in table 2. how to do it on clicking button using JS/jquery on clientside? Table 1 is - <table class="table loadTable" id ="table1"> <thead> <tr bgcolor="#f0f0f0"> <td nowrap=""><b>COLUMN_NAME</b></td> <td nowrap=""><b>DATA_TYPE</b></td> <td nowrap=""><b>IS_NULLABLE</b></td> <td nowrap=""><b>CHARACTER_MAXIMUM_LENGTH</b></td> <td nowrap=""><b>NUMERIC

Grails <g:if> in <g:select>

有些话、适合烂在心里 提交于 2019-12-11 07:43:12
问题 I have this <g:select> in a .gsp file. But unlike any ordinary <g:select> 's this one would have the attribute disabled="" if a certain condition is met. Following the code: <g:select name="test" from="${["foo1","foo2"]}" <g:if test="${true}">disabled=""</g:if> /> It returned an error: Grails tag [g:select] was not closed But when I change it into this: <g:select name="test" from="${["mu1","mu2","mu3"]}" ${ if(true) { println "disabled=\"\"" } }/> It returned this error: Attribute value must

Grails URL mapping cause error on GSP

谁说胖子不能爱 提交于 2019-12-11 06:57:07
问题 I have a site that have URL similar to this: /mysite/admin/controller/action/id /mysite/search/controller/action/id /mysite/user/controller/action/id I have my URL mapping like this "/$prefix/$controller/$action?/$id?"{ constraints {} } I am able to get to the controller correctly. But on the GSP side <g:link controller="controller">abc</g:link> ==> <a href="/mysite/controller/...">abc</a> Notice how I lose the prefix between mysite and the controller. 回答1: You can use named url mappings and

How to use grails <g:set> tag session scope?

本秂侑毒 提交于 2019-12-11 06:56:43
问题 I am trying to use the g:set tag on my gsp. As long as I am in one page and the scope is default or page, it works fine. When I am trying to change the scope to session its not working. My understanding is I should be able to access that variable not only on that page but also on others when the scope is session, however, I might be wrong. In a brand new 2.0.3 application I have this script on my index.gsp body and it works as expected. <g:set var="bar" value="${new Date() - 7}" scope="page"

Class 'Google\Cloud\Storage\StorageClient' not found

走远了吗. 提交于 2019-12-11 06:46:59
问题 use Google\Cloud\Storage\StorageClient; require __DIR__ . '\vendor\autoload.php'; $storage = new StorageClient(); That as my code.Here I have installed composer on windows and getting following error:- Fatal error: Class 'Google\Cloud\StorageClient' not found in C:\xampp\htdocs\fingertips\application\controllers\teacher.php on line 214 And even after running commands with composer to use google cloud api's, then also nothing is happening. On cmd, when I am running this, "composer require

Is there a way to do gsp partials rather than tag libraries?

こ雲淡風輕ζ 提交于 2019-12-10 21:43:53
问题 One of the things I liked about freemarker is that you can quickly create new macros that encapsulate complex html to make the pages smaller and more concise. Do I have to make tag libraries to do the same thing in grails, or is there a really light-weight syntax for achieving the same thing? 回答1: There is a <g:render> tag, which may match your needs. It's documented here. 来源: https://stackoverflow.com/questions/2903353/is-there-a-way-to-do-gsp-partials-rather-than-tag-libraries

Font not applied in my web application

我与影子孤独终老i 提交于 2019-12-10 11:59:54
问题 I am working on grails web application in which I am trying to apply a font named open sans but it is not applied in my web application. The procedure which I have followed is: I have put the code below in me extended.css file @font-face { src: url('../../images/font/openSans.woff'); font-family: 'open sans'; /*url('openSans.woff') format('woff'),*/ font-style: normal; font-weight: normal; } body{ font-family: 'open sans'; } What am I missing? 回答1: Open Sans is a Google font, you can use it