POJO Objects to HTML editable tables and back


I am using struts 2 and tiles 2. I want to display a list of POJO objects in HTML editable tables. If the user makes a change to one row I would like this change to channel back to the underlying POJO object by clicking on a save button. I dont mind a save button been on each row.The attributes of the POJO are the columns.

If I have to submit all the rows just to update one row then so be it.  I have looked at a few DOJO/JSON tutorials on the web but none seem to be editable and persist back to the POJO.

I would love a full tutorial link or sample code to get me started. It doesnt have to to be DOJO/JSON

Who is Participating?
Murali MurugesanConnect With a Mentor Full stack Java developerCommented:
Ideally the steps should be ,

1.Convert you list of POJO to a JSON or XML file.
2. And follow the approach as mentioned in the url that i have attached.
3. On editing the grid your JSON file gets updated.
4. On final click of save button reload the json file as a list of your POJO objects and play with it.

http://www.json.org/java/ -- some samples to read a JSON file.

NOTE: even an valid xml file is accepted by JSON, as you might be aware.

Murali MurugesanFull stack Java developerCommented:
MBUNITEDAuthor Commented:
OK I had a look at it. I havent seen this link before.
Im slightly confused as I dont know enough so I have a few simple questins then ill award the points...

From what i can see I can use JSON|(JSON URL) and the dodjo.data API to retrieve data from my List of POJOs. Put this data into a grid/table. THE json URL will be a action that simply returns JSON version of my list of POJOs?

Then I can edit the table, and this will reflect in my data store (i.e. my POJO object immediatedly through JSON/AJAX)?

I will start using simple tutorials of thsi and build up to what i need.

If it is the
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Murali MurugesanFull stack Java developerCommented:
Yes you are right. The complete process of rendering and editing is within UI scope and nothin goes beyond tat. You need to have the implementation to take the data back to db.

you could also use ExtJs which is great for such things. this looks like what you want: http://www.extjs.com/deploy/dev/examples/grid/edit-grid.html (demo code is downloadable). you only had to use a JsonReader instead of an XmlReader.

Principle is similar to DOJO. you have a local store which gets updated and fires "updates" towards the server. there you have to write an action class to catch and parse the incoming date, pass it on to the db and thats about it...
MBUNITEDAuthor Commented:
But of I edit the table. Does this edit my POJO. Im not worried about the DB. I just want chnages in teh grid to reflect in my POJO.

Ideally if one row changes then just one POJO in my LIST of POJO updates
Or by submitting do all POJOs update including ones that never changed.
If thats the case ill get over that. I just want a grid that upon changing will change my POJO
MBUNITEDAuthor Commented:
Thank for you time and being patient with answering my questions. im now downloading DOJO and going to play with it. With the aim to incorportating it into my site. thanks for the other poster suggesting ext-js but i think Dojo is more popular at the moment.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.