Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AC69911C15 for ; Fri, 16 May 2014 16:21:53 +0000 (UTC) Received: (qmail 29023 invoked by uid 500); 16 May 2014 11:08:20 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 90593 invoked by uid 500); 16 May 2014 10:54:37 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 63012 invoked by uid 99); 16 May 2014 10:38:49 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2014 10:38:49 +0000 Received: from localhost (HELO mail-yk0-f172.google.com) (127.0.0.1) (smtp-auth username lukaszlenart, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2014 09:48:56 +0000 Received: by mail-yk0-f172.google.com with SMTP id 79so1925405ykr.17 for ; Fri, 16 May 2014 02:48:55 -0700 (PDT) X-Received: by 10.236.46.225 with SMTP id r61mr23986357yhb.107.1400233735479; Fri, 16 May 2014 02:48:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.170.194.130 with HTTP; Fri, 16 May 2014 02:48:35 -0700 (PDT) In-Reply-To: <536B31EA.1060506@gmail.com> References: <536B31EA.1060506@gmail.com> From: Lukasz Lenart Date: Fri, 16 May 2014 11:48:35 +0200 Message-ID: Subject: Re: ModelDriven and ParamsPrepareParams To: Struts Users Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=C3=A1nchez : > 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() !=3D null) { > person =3D service.getPerson(person.getId()); > } else { > person =3D new Person(); > } > } > > do > > @Override > public void prepare() throws Exception { > if (personId !=3D null) { > person =3D service.getPerson(personId); > } else { > person =3D new Person(); > } > } > > doing the same in the view, using personId appropriately instead of (mode= l) > 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-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org