开发者

Array of objects in Javascript - Struts Forms

This is for a web application using st开发者_开发百科ruts.

I have an array of objects in my Form that gets listed in a table. A user can add/edit/delete from the table. How would I send the changed table back to the Action class?

Will I need to create a string or array of strings, and parse that into an object? Is there a way that java/struts handles objects that are to be modified in the jsp? Or does this need to be cared for in javascript?


Struts binds the request parameters onto the ActionForm object based on name of the input.

actionFormObj.setBla(String x) { ... } matches <input name="bla"... in the form.

When you have related inputs, you can use maps or arrays for ActionForm properties and Struts is smart enough to treat them as well. See here.

Additionally, if your table contains read-only data that you switch to input when editing, you might have to deal with a lot of hidden fields in your form. If you still consider JavaScript as an option, you could create a POST request based on a JavaScript object (that you create with whatever data you wish from the table) and then use jQuery to send it. See here.


Indexed properties in struts, apparently takes care of this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜