I think you should use JSON for that usecase.  Object arrayLists in JSON
are simple enough to use.

JSON:
------------------------------------------------------------------------
--------

        rows = [
                {id:1,name:'field1'},
                {id:2,name:'field2'}
        ];

------------------------------------------------------------------------
--------


JavaScript:
------------------------------------------------------------------------
--------

        var table = '<table id="tbl">';
        for(var i=0,il=rows.length; i<il; i+=1) {
                var row = rows[i];
                table += '<tr id="tbl-row-' + i + '">';
                table += '      <td id="tbl-row-' + i + '-id">' + row.id
+ '</td>';
                table += '      <td id="tbl-row-' + i + '-name">' +
row.name + '</td>';
                table += '</tr>';
        }
        table += '</table>';

------------------------------------------------------------------------
--------

That's how I'd do it.  Hope that helps!

Beez

-----Original Message-----
From: Anjib Mulepati [mailto:anji...@hotmail.com] 
Sent: Wednesday, December 01, 2010 1:56 PM
To: Struts Users Mailing List
Subject: Re: Calling Struts Action from JavaScript

Ok

JSON seems to be easy way to represent the complex result. But I am
still confuse whether I should use JSON or not?

My result are set of records from the database so it have tabular form. 
For that reason I am using Arraylist of Object and putting those result
in arraylist.

Is this a good practice?

Anjib


On 12/1/2010 10:26 AM, Biesbrock, Kevin wrote:
> Example: http://www.json.org/example.html
>
> All the information you could want and so much more:
> http://www.google.com/search?q=json
>
>
> Beez
>
> -----Original Message-----
> From: Anjib Mulepati [mailto:anji...@hotmail.com]
> Sent: Wednesday, December 01, 2010 10:24 AM
> To: Struts Users Mailing List
> Subject: Re: Calling Struts Action from JavaScript
>
> Can you please write me simple example of this JSON? I have never used

> this.
>
> Anjib
> On 12/1/2010 10:13 AM, Li Ying wrote:
>> 2010/12/1 Anjib Mulepati<anji...@hotmail.com>:
>>> Li
>>> When you say sending response using JSON what does that mean?
>> I mean, send a string in JSON format as response.
>>
>> If your response is simple, for example, just a "OK" or "ERROR" flag,

>> you can use plain text.
>>
>> But when you need send a complex data strut back to client side, for 
>> example, FLAG=ERROR ERROR_MESSAGE=["input data duplication", "age is 
>> out of range"] ......
>>
>> It will be hard to express in plain text format, so XML or JSON is a 
>> better choice.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to