You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Leon Derks <le...@cumquat.nl> on 2008/05/14 14:24:01 UTC
T5: JSONArray + fillling
Hello
I found this example:
new JSONArray("[['a', 'value a'], ['b', 'value b'], ['c', 'value c'],
['d', 'value d']]"));
The JSONArray contains information for my select box, with a value -
label pair.
But in my case, I want to make a new JSONArray filled with properties
from my List of Groups.
So for example something like this:
for(Group group : List<Group> groups) {
jsonArray.put(group.getId, group.getName());
}
The problem is that a put operation only allows put(Object value) and
put(int index, Object value);
How can I add the group.getId and group.getName() as a value-label pair
to the JSONArray?
Leon
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: JSONArray + fillling
Posted by Sven Homburg <ho...@googlemail.com>.
http://www.prototypejs.org/learn/json
2008/5/15 Leon Derks <le...@cumquat.nl>:
> Thanks,
>
> How can I loop through the jsonObjects in javascript?
>
> I have now something like this:
>
> array.each(function(item) {
> item[0] item[1]
> //fill options with the item.
> }
>
> But I get undefined text in for my select option values.
> The number of items in my select is correct, but the key-value is set to
> "undefined"
>
> Leon
>
>
> Lance Java wrote:
>
>> JSONArray options = new JSONArray();
>> for(Group group : List<Group> groups) {
>> JSONObject obj = new JSONObject();
>> obj.put(group.getId, group.getName());
>> options.put(obj);
>> }
>>
>> Cheers,
>> Lance.
>>
>> 2008/5/14 Leon Derks <le...@cumquat.nl>:
>>
>>
>>
>>> Can you give me an example of that?
>>>
>>> Leon
>>>
>>>
>>> Lance Java wrote:
>>>
>>>
>>>
>>>> You want a JSONObject not a JSONArray
>>>> http://tapestry.formos.com/nightly/tapestry5/apidocs/index.html
>>>>
>>>> Cheers,
>>>> Lance.
>>>>
>>>> 2008/5/14 Leon Derks <le...@cumquat.nl>:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Hello
>>>>>
>>>>> I found this example:
>>>>>
>>>>> new JSONArray("[['a', 'value a'], ['b', 'value b'], ['c', 'value c'],
>>>>> ['d',
>>>>> 'value d']]"));
>>>>>
>>>>> The JSONArray contains information for my select box, with a value -
>>>>> label
>>>>> pair.
>>>>>
>>>>> But in my case, I want to make a new JSONArray filled with properties
>>>>> from
>>>>> my List of Groups.
>>>>>
>>>>> So for example something like this:
>>>>>
>>>>> for(Group group : List<Group> groups) {
>>>>> jsonArray.put(group.getId, group.getName());
>>>>> }
>>>>>
>>>>> The problem is that a put operation only allows put(Object value) and
>>>>> put(int index, Object value);
>>>>>
>>>>> How can I add the group.getId and group.getName() as a value-label pair
>>>>> to
>>>>> the JSONArray?
>>>>>
>>>>> Leon
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
Re: T5: JSONArray + fillling
Posted by Leon Derks <le...@cumquat.nl>.
Thanks,
How can I loop through the jsonObjects in javascript?
I have now something like this:
array.each(function(item) {
item[0] item[1]
//fill options with the item.
}
But I get undefined text in for my select option values.
The number of items in my select is correct, but the key-value is set
to "undefined"
Leon
Lance Java wrote:
> JSONArray options = new JSONArray();
> for(Group group : List<Group> groups) {
> JSONObject obj = new JSONObject();
> obj.put(group.getId, group.getName());
> options.put(obj);
> }
>
> Cheers,
> Lance.
>
> 2008/5/14 Leon Derks <le...@cumquat.nl>:
>
>
>> Can you give me an example of that?
>>
>> Leon
>>
>>
>> Lance Java wrote:
>>
>>
>>> You want a JSONObject not a JSONArray
>>> http://tapestry.formos.com/nightly/tapestry5/apidocs/index.html
>>>
>>> Cheers,
>>> Lance.
>>>
>>> 2008/5/14 Leon Derks <le...@cumquat.nl>:
>>>
>>>
>>>
>>>
>>>> Hello
>>>>
>>>> I found this example:
>>>>
>>>> new JSONArray("[['a', 'value a'], ['b', 'value b'], ['c', 'value c'],
>>>> ['d',
>>>> 'value d']]"));
>>>>
>>>> The JSONArray contains information for my select box, with a value -
>>>> label
>>>> pair.
>>>>
>>>> But in my case, I want to make a new JSONArray filled with properties
>>>> from
>>>> my List of Groups.
>>>>
>>>> So for example something like this:
>>>>
>>>> for(Group group : List<Group> groups) {
>>>> jsonArray.put(group.getId, group.getName());
>>>> }
>>>>
>>>> The problem is that a put operation only allows put(Object value) and
>>>> put(int index, Object value);
>>>>
>>>> How can I add the group.getId and group.getName() as a value-label pair
>>>> to
>>>> the JSONArray?
>>>>
>>>> Leon
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: JSONArray + fillling
Posted by Lance Java <la...@googlemail.com>.
JSONArray options = new JSONArray();
for(Group group : List<Group> groups) {
JSONObject obj = new JSONObject();
obj.put(group.getId, group.getName());
options.put(obj);
}
Cheers,
Lance.
2008/5/14 Leon Derks <le...@cumquat.nl>:
> Can you give me an example of that?
>
> Leon
>
>
> Lance Java wrote:
>
>> You want a JSONObject not a JSONArray
>> http://tapestry.formos.com/nightly/tapestry5/apidocs/index.html
>>
>> Cheers,
>> Lance.
>>
>> 2008/5/14 Leon Derks <le...@cumquat.nl>:
>>
>>
>>
>>> Hello
>>>
>>> I found this example:
>>>
>>> new JSONArray("[['a', 'value a'], ['b', 'value b'], ['c', 'value c'],
>>> ['d',
>>> 'value d']]"));
>>>
>>> The JSONArray contains information for my select box, with a value -
>>> label
>>> pair.
>>>
>>> But in my case, I want to make a new JSONArray filled with properties
>>> from
>>> my List of Groups.
>>>
>>> So for example something like this:
>>>
>>> for(Group group : List<Group> groups) {
>>> jsonArray.put(group.getId, group.getName());
>>> }
>>>
>>> The problem is that a put operation only allows put(Object value) and
>>> put(int index, Object value);
>>>
>>> How can I add the group.getId and group.getName() as a value-label pair
>>> to
>>> the JSONArray?
>>>
>>> Leon
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: T5: JSONArray + fillling
Posted by Leon Derks <le...@cumquat.nl>.
Can you give me an example of that?
Leon
Lance Java wrote:
> You want a JSONObject not a JSONArray
> http://tapestry.formos.com/nightly/tapestry5/apidocs/index.html
>
> Cheers,
> Lance.
>
> 2008/5/14 Leon Derks <le...@cumquat.nl>:
>
>
>> Hello
>>
>> I found this example:
>>
>> new JSONArray("[['a', 'value a'], ['b', 'value b'], ['c', 'value c'], ['d',
>> 'value d']]"));
>>
>> The JSONArray contains information for my select box, with a value - label
>> pair.
>>
>> But in my case, I want to make a new JSONArray filled with properties from
>> my List of Groups.
>>
>> So for example something like this:
>>
>> for(Group group : List<Group> groups) {
>> jsonArray.put(group.getId, group.getName());
>> }
>>
>> The problem is that a put operation only allows put(Object value) and
>> put(int index, Object value);
>>
>> How can I add the group.getId and group.getName() as a value-label pair to
>> the JSONArray?
>>
>> Leon
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: JSONArray + fillling
Posted by Lance Java <la...@googlemail.com>.
You want a JSONObject not a JSONArray
http://tapestry.formos.com/nightly/tapestry5/apidocs/index.html
Cheers,
Lance.
2008/5/14 Leon Derks <le...@cumquat.nl>:
> Hello
>
> I found this example:
>
> new JSONArray("[['a', 'value a'], ['b', 'value b'], ['c', 'value c'], ['d',
> 'value d']]"));
>
> The JSONArray contains information for my select box, with a value - label
> pair.
>
> But in my case, I want to make a new JSONArray filled with properties from
> my List of Groups.
>
> So for example something like this:
>
> for(Group group : List<Group> groups) {
> jsonArray.put(group.getId, group.getName());
> }
>
> The problem is that a put operation only allows put(Object value) and
> put(int index, Object value);
>
> How can I add the group.getId and group.getName() as a value-label pair to
> the JSONArray?
>
> Leon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>