Hi Greg,

the thing about ModelDriven is that the model object gets pushed on the
value stack _before_ your action method is executed. To initialize the
model object before the ModelDrivenInterceptor comes into play, just
implement Preparable and do your initialization in prepare() (as Lukasz
already suggested)

- René

Greg Stasica schrieb:
> hi,
> 
> the scenario is as follow:1
> 1. class EditMyBeanAction implements Model...
> 2. url mapping calls edit method on the EditMyBeanAction
> 3. the result should be that once edit method returns (it loads MyBean
> object from the database) MyBean should be displayed on the jsp
> 
> the problem is that it seems like with hibernate it doesn't work at least
> when used as below (reassigned object addresses)
> 
> classs EditMyBeanAction  implements Model ..<MyBean>
> 
> private MyBean bean = new MyBean();
> 
> public MyBean getModel()
> {
> return bean;
> }
> 
> public String edit()
> {
>  MyBean mb = hibernateFacade.loadMyBeanObjectById(123);
> // bean.setName("test")    ----- 2
> bean = mb;    // 3
> return "success";
> 
> }
> 
> 
> i suspect that the problem is somewhere around proxy classes either in
> hibernate or ognl (i would rather start to look here though) because if i
> uncomment line 2 and comment out 3 i'm getting the test value on the name
> property.
> 
> surely the workaround is to:
> 1. copy properties from one object to another but again this is simply a
> waste of memory :)
> 2. get the MyBean object in getModel() method but i don't think this method
> should do any dao/business operations
> 

-- 
René Gielen
http://twitter.com/rgielen

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to