开发者

Multiple Model Objects for fields in one form in Struts 2

We have a JSP page which shows details from multiple beans. Now, there is a requirement to edit the details of these individual beans and persist it into the database. So what we are doing is having one 开发者_高级运维form with appropriate fields for each individual bean. But the ModelDriven interface allows only one object. So all the fields values will not get populated. And we cannot save the details. What can be done in this case???


Probably you can wrap your beans into single Class and provide get/set methods?

public class ModelWrapper {
    private Bean1 bean1;
    private Bean1 bean2;

    public getBean1Param1() {
        return bean1.getParam1();
    }
    ...
    public getBean2Param1() {
        return bean2.getParam1();
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜