Solved

POJO Objects to HTML editable tables and back

Posted on 2009-05-13
7
1,448 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now