Solved

POJO Objects to HTML editable tables and back

Posted on 2009-05-13
7
1,458 Views
Last Modified: 2013-11-24
Hi,

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

Thanks
0
Comment
Question by:MBUNITED
  • 3
  • 3
7 Comments
 
LVL 13

Expert Comment

by:Murali Murugesan
ID: 24382233
0
 

Author Comment

by:MBUNITED
ID: 24384197
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.
Thanks




If it is the
0
 
LVL 13

Expert Comment

by:Murali Murugesan
ID: 24384367
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.

Thanx
-Murali*
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:OliG
ID: 24384371
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...
0
 

Author Comment

by:MBUNITED
ID: 24387626
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
0
 
LVL 13

Accepted Solution

by:
Murali Murugesan earned 250 total points
ID: 24393118
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*
0
 

Author Closing Comment

by:MBUNITED
ID: 31581228
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.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question