Getting domain class values in Javascript(gsp)
I want to retrieve ALL values set in my domain class to the client side
(gsp or Javascript) Let's say I have a domain class named GeneralSetting.
The approach I used works but not completely how I want.
gsp file
<%
def test = com.domain.GeneralSetting.findAll()[0]
def test1 = com.domain.GeneralSetting.findAll()[0].color
%>
Js
console.debug('${test}'); OUTPUT: [com.domain.GeneralSetting : 1]
console.debug('${test1}'); OUTPUT: red
I was thinking about something like this:
def globalSettings = com.digithurst.gutmann.domain.GeneralSetting.getAll()[0]
def array = []
//Add all properties
globalSettings.each {
array.add(it);
}
But when I ouput the array i just keep getting this:
[com.domain.GeneralSetting : 1] instead of all the properties
No comments:
Post a Comment