Number 2 is also my favorite but it quite often depends ... on dev's
preferences :D

I remember that I wanted solve that case with ParametersInterceptors
but there was a problem when and how to instantiate Model .

2014-05-08 9:27 GMT+02:00 Antonio Sánchez <ads...@gmail.com>:
> Hello.
>
> I have found problems using MD and PPP together, Struts2 complains (and
> errors are displayed in view) that no setter method was found because at
> first Params run, model is not yet instantiated. I am asking for which of
> the following approaches is the most recommended one:
>
> 1. Define a custom interceptor stack MPPP (ModelParamsPrepareParams), so
> model is instantiated before first params.
>
> 1.1. I have read [1] than moving ModelDriven would not be enough, but a
> MPPMP is required. Is this right?
>
> 2. [my preferred one] Define a (redundant) id property in the action and use
> it in the action and in the view instead of the id property of the model. I
> mean, instead of:
>
>     @Override
>     public void prepare() throws Exception {
>         if (person.getId()  != null) {
>             person = service.getPerson(person.getId());
>         } else {
>             person = new Person();
>         }
>     }
>
> do
>
>     @Override
>     public void prepare() throws Exception {
>         if (personId  != null) {
>             person = service.getPerson(personId);
>         } else {
>             person = new Person();
>         }
>     }
>
> doing the same in the view, using personId appropriately instead of (model)
> id.
>
> 3. Do not use ModelDriven.
>
> Any other one? Is this issue documented?
>
> Thanks.
>
> [1] http://blog.mattsch.com/2011/04/14/things-discovered-in-struts-2/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>

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

Reply via email to