开发者

Dynamic Tables with Struts 2

开发者 https://www.devze.com 2023-02-15 17:56 出处:网络
What would be the best way to create a dynamic HTML table using the JQuery plugin? What I want to do is be able to pull data from my action class and be ableto perform CRUD operations on that data whi

What would be the best way to create a dynamic HTML table using the JQuery plugin? What I want to do is be able to pull data from my action class and be able to perform CRUD operations on that data which is presented in a table. I also want to be able to dynamically add rows to the table as well and have it saved server side.

I found this example but it uses Dojo and I'm trying to stay away from using the Dojo 开发者_StackOverflow中文版Struts plugin since it is so old.

The Struts2 JQuery Grid plugin looks like a possible solution.

Would this be a good use case to use a plugin like Freemarker?


Last time I had to do something similar I used Direct Web Remoting. The JARs might even come with Struts2, but I don't remember. Basically, you have an object in JavaScript that looks like an object back on your server, and it handles the AJAX for you. With this approach, your JS code can look like this:

ObjectHandler.destroyObject(someId);

DWR will then make an AJAX request, calling the Java ObjectHandler#destroyObject(int). Of course, you can also ask ObjectHandler for an array of data or whatever you like to create the table.

DWR can actually be very convenient, but the setup can take some time. (Nothing a Java Web Dev isn't use to, though. ;-))


I would just use jquery without the jquery plugin and use the struts2-json-plugin instead of DWR it provides SMD.

See: https://cwiki.apache.org/confluence/display/WW/JSON%20Plugin


The Struts2 jQuery Grid Plugin can be a good solution. It is a fast way to create a AJAX Table with CRUD Operations and you can find a lot of tutorials about.


I used jquery Gridnic. It is very easy to start with

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号