|
Hi, i am trying to answer an JSON Request with a list of all Items but I need to remove one of the properties of each element. When I use: render DomainClass.list as JSON it gives back a list of all elements with all properties. When I use: render DomainClass.list().each { it.property = null} as JSON it gives back the result which I need but it also deletes the property of each element directly in the database. Is there an easy way to get the second result without touching the Element properties stored in the database? Thank you for your help. Markus |
|
You'll probably want to do something like this:
import grails.converters.JSON; import org.codehaus.groovy.grails.web.json.* import com.visionarysoftwaresolutions.restaurant.* def moo = new Ingredient(name:"poop").save() def loo = new JSONArray((Ingredient.list() as JSON).toString()) println loo loo.each() { println it it.remove("id") println it } Upvote for adding a method to the grails.converters.JSON to return a JSONElement (which would probably be done by calling parse() on the result of its toString() after evaluating the passed in object) 2011/6/18 Markus Plänitz <[hidden email]>
|
|
I'm trying use grails with jquery mobile, the basic structure of a jquery mobile page is something like this
<div data-role="page" id="thePageId"> <div data-role="header">...</div> <div data-role="content">...</div> <div data-role="footer">...</div> </div>All pages are basically defined in one html page with the data-role="page" defining what the current page/view is. In the above example I would like to have my main mobile layout define this format but I need to somehow override the 'thePageId' in each page using this layout in order to use jquery mobile effectively since the id of the page is used in various areas of the library. I would need something like: Thanks |
|
I had sent this before I completed so continuing: ... I would need something like: <div data-role="page" id="${thePageId}"> In the main layout where the value is set in each page if this is
possible
Thanks From: "[hidden email]" <[hidden email]> To: [hidden email] Sent: Sat, June 18, 2011 4:58:36 PM Subject: [grails-user] Overriding values in main layout template from within pages? I'm trying use grails with jquery mobile, the basic structure of a jquery mobile page is something like this <div data-role="page" id="thePageId"> <div data-role="header">...</div> <div data-role="content">...</div> <div data-role="footer">...</div> </div>All pages are basically defined in one html page with the data-role="page" defining what the current page/view is. In the above example I would like to have my main mobile layout define this format but I need to somehow override the 'thePageId' in each page using this layout in order to use jquery mobile effectively since the id of the page is used in various areas of the library. I would need something like: Thanks |
|
Ok so I can do it using a filter and setting a value in the model to use for the id value. If there is a better way than this I would like to hear it.
Thanks From: "[hidden email]" <[hidden email]> To: [hidden email] Sent: Sat, June 18, 2011 5:06:53 PM Subject: Re: [grails-user] Overriding values in main layout template from within pages? I had sent this before I completed so continuing: ... I would need something like: <div data-role="page" id="${thePageId}"> In the main layout where the value is set in each page if this is
possible
Thanks From: "[hidden email]" <[hidden email]> To: [hidden email] Sent: Sat, June 18, 2011 4:58:36 PM Subject: [grails-user] Overriding values in main layout template from within pages? I'm trying use grails with jquery mobile, the basic structure of a jquery mobile page is something like this <div data-role="page" id="thePageId"> <div data-role="header">...</div> <div data-role="content">...</div> <div data-role="footer">...</div> </div>All pages are basically defined in one html page with the data-role="page" defining what the current page/view is. In the above example I would like to have my main mobile layout define this format but I need to somehow override the 'thePageId' in each page using this layout in order to use jquery mobile effectively since the id of the page is used in various areas of the library. I would need something like: Thanks |
| Powered by Nabble | Edit this page |
