gsp

Correctly pass a Groovy list to Javascript code in GSP

ε祈祈猫儿з 提交于 2019-11-30 07:01:20
问题 I'm making a web application with Grails. I've got a list with data that must be included on JavaScript to perform some dynamic load on <select> drop-list. Basically, I'm getting a two level list from the server, then the first level is presented on a drop box. When the user selects an option, the list associated to this option is presented on another drop box. The (simplified) code on the gsp page for the JavaScript function is the following function selecTipe() { var types = ${typeList}

How can I change the way GRAILS GSP fieldValue formats Integers?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 02:31:31
I have a field in my domain object which I define as an Integer... Integer minPrice I then access it in a GSP page as follows: ${fieldValue(bean: myBean, field: 'minPrice')} and what I get in my HTML is... 100,000 which is not an Integer, it's a String. Worse still it's a formatted String in a particular locale. This is a problem because I have a SELECT control on an HTML FORM which has a (non-ordinal) range of values for minPrice which I want to store in my domain object as integers, and I don't want to store an index to some array of values that I have to repeatedly map back and forth

Rendering HTML files in Grails

无人久伴 提交于 2019-11-29 02:13:27
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 <g:render> templates which are delivered as html files. For this, as we know, html files have to be converted to _foo.gsp files in order to get rendered. I am totally surprised as to why isn't there a direct support for html or is there one?? Thanks! One obvious option is to simply rename your HTML files from foo.html to _foo.gsp and then use <render template="foo"> . However this is so obvious that I'm sure you've already thought of it. If you simply want to

Correctly pass a Groovy list to Javascript code in GSP

给你一囗甜甜゛ 提交于 2019-11-29 00:28:15
I'm making a web application with Grails. I've got a list with data that must be included on JavaScript to perform some dynamic load on <select> drop-list. Basically, I'm getting a two level list from the server, then the first level is presented on a drop box. When the user selects an option, the list associated to this option is presented on another drop box. The (simplified) code on the gsp page for the JavaScript function is the following function selecTipe() { var types = ${typeList} alert('List of types ' + types ) The problem is that, if typeList is defined (in Groovy) as typeList = [[

How do I call a Grails service from a gsp?

☆樱花仙子☆ 提交于 2019-11-27 19:02:22
How can I invoke a service directly from a view? I'm trying with ${my.domain.service.method} , but it complains it can't find the property. And no, I don't want to use a controller because the view is a template. <%@ page import="com.myproject.MyService" %> <% def myService = grailsApplication.classLoader.loadClass('com.myproject.MyService').newInstance() %> And then you can call ${myService.method()} in your gsp view Be aware that calling transactional service methods from views hurts performance. Better to move all your transactional service method calls to the controller (if you can)

Rendering HTML files in Grails

≡放荡痞女 提交于 2019-11-27 16:35:34
问题 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 <g:render> templates which are delivered as html files. For this, as we know, html files have to be converted to _foo.gsp files in order to get rendered. I am totally surprised as to why isn't there a direct support for html or is there one?? Thanks! 回答1: One obvious option is to simply rename your HTML files from foo.html to _foo.gsp and then use <render

Can't mark while showing the current location in 'mapview'

只谈情不闲聊 提交于 2019-11-27 09:10:22
Hear is my project In my project I am showing my current location,showing the current lat-long.But I'm not able to mark my current position in android. Thnx in advance. @Override public void onLocationChanged(Location location) { // TODO Auto-generated method stub Log.d(TAG, "onLocationChanged with location " + location.toString()); // Displays lat, long, altitude and bearing String text = String.format("Lat:\t %f\nLong:\t %f\nAlt:\t %f\nBearing:\t %f", location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getBearing()); this.locationText.setText(text); try { //

Open pdf file in new window from variable path name in GSP page

泪湿孤枕 提交于 2019-11-26 18:37:47
问题 I have a map named file I'm receiving from my controller which contains the path and description of a file stored in assets/myfiles/file.pdf the following format: {"filepath": "file.pdf", "description": "something"} How do I create a link to this pdf in a GSP page I'm rendering? <a href="${resource(dir: 'myfiles', file:' ${file[filename])' }" target="_blank">${file[description]}</a> I tried the above but it doesn't open the pdf but just another cloned tab of the app 回答1: Create Controller

Overriding grails.views.default.codec=&#39;html&#39; config back to &#39;none&#39;

元气小坏坏 提交于 2019-11-26 12:56:06
问题 In Grails (<2.3), 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 set the default to \'html\' , how do I get back to \'none\' for one expression when I don\'t want the HTML encoding behavior? 回答1: If