Solved

POJO Objects to HTML editable tables and back

Posted on 2009-05-13
7
1,444 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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)

744 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

11 Experts available now in Live!

Get 1:1 Help Now