You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Umesh Awasthi <um...@gmail.com> on 2013/10/15 13:32:32 UTC
Question about Model Driven Interface
Hi All,
Have rarely used model driven interface and not sure about how exactly it
work.
Can any one point me what will be difference between
ProfileDTOModel md = new ProfileDTOModel();
publicProfileDTOModel getModel()
{
return md;
}
and
public ProfileDTOModel getModel()
{
return new ProfileDTOModel();;
}
--
With Regards
Umesh Awasthi
http://www.travellingrants.com/
Re: Question about Model Driven Interface
Posted by Amol Ghotankar <gh...@gmail.com>.
Hi Umesh,
Both you mentioned are same.
ModelDriven is best used to create new object if they do not exist.
So your getModel method must be
ProfileDTOModel md;
public ProfileDTOModel getModel()
{
if(md != null)// Or Some other condition as required by your model.
Typically check for Id
{
return md;
}
md = new ProfileDTOModel();
return md;
}
Here if you use modelDriven interceptor, model objects are cached in
ValueStack (or autopushed) between your edits in one way.
But you also need to use prepare and params interceptor to take full
adavantage of this.
Struts2 experts correct my langauge if required.
On Tue, Oct 15, 2013 at 5:02 PM, Umesh Awasthi <um...@gmail.com>wrote:
> Hi All,
>
> Have rarely used model driven interface and not sure about how exactly it
> work.
> Can any one point me what will be difference between
>
> ProfileDTOModel md = new ProfileDTOModel();
>
>
> publicProfileDTOModel getModel()
> {
>
> return md;
> }
>
> and
>
> public ProfileDTOModel getModel()
> {
>
> return new ProfileDTOModel();;
> }
>
>
> --
> With Regards
> Umesh Awasthi
> http://www.travellingrants.com/
>
--
*With Best Regards,*
Amol Ghotankar
Technical Lead
M: +91 9960 980 419 <http://www.cursivetech.com>