开发者

How to create a form to edit an object and its child-objects?

Im using Struts2 and Hibernate, trying to create a simple form to edit an object and all its children (one-to-many).

I've attached an image to show what im trying to do.

Does anyone have any idea/examples of how I can do this the easiest way? I just cannot understand how to create this kind of form. I've looked for answers for 2 days now, without getting anywhere.

I have been able to create the simple person开发者_如何学JAVA-form and persisting it, and I have also been able to display a list of the pets in the form, but I have not come any closer to a solution as to how to create new pets and edit them.


The easiest way is probably to use ajax; this way adding/editing a pet can be persisted immediately and the owner can be persisted when submitting the form. The other solution would be to add all the information into the request when submitting the form and figuring out in your Action class what to do; it is feasible but will require some thinking and javascript (although also for the ajax solution you will require this).


As you are using struts 2 the i would suggest you to go the struts2 jquery pluginits the best thing you want as per your image requirment.

Visit it

Agoing to the page go to grid tab.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜