Please download this and run it. I think it's worth trying though it'll be a little annoying.
In execute method of action class, if you set the bean by the method returning beans, Modeldriven won't work in JSP( <s:property "someField" />
won't work so you have to type the bean instance name like this; <s:property "myBean.someField" />
).
But if you set the bean's field value, Modeldriven will work.
I know you may not believe me and think there's something else that I did wrong. But it's not true! Just try it..
public class DefaultClass extends ActionSupport implements ModelDriven<TestBean> {
TestBean test = new TestBean();
DAO db = DAO.getInstance();
public String access() throws Exception {
//Beans setter doesn't work!
setTest( db.getTest() );
return SUCCESS;
}
public String access2() throws Exception {
//Field setter works!
test.setA(db.getA());
test.setB(db.getB());
return SUCCESS;
}
I didn't know what I just found. So I ask this question. And as my own answer, if I push the bean to the valuestack Modeldriven will work.
I wonder why there's no question about this. I think it's a serious problem.