You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by frankiestd168 <ch...@hotmail.com> on 2006/11/08 16:44:59 UTC

Struts2, "model-driven" interceptors

this is a question for Struts2 interceptors..

I saw some examples, the action class implements ModelDriven,
<interceptor-ref name="model-driven"/>

So this function is added in action class:

public Object getModel() {
       return user;
}

Then jsp can directly access the properties of the User object.

Beside this, what is the benefit of using this interceptor ?
Is that only for jsp purpose?


-- 
View this message in context: http://www.nabble.com/Struts2%2C-%22model-driven%22-interceptors-tf2595966.html#a7240831
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts2, "model-driven" interceptors

Posted by Ted Husted <hu...@apache.org>.
With model-driven, we don't need to prefix the property references
with "model." or "user.". We can also do things like mix and match
properties from the model and the Action, without adding extra
references. For example, a model object might have a password
property, but it won't have a passwordConfirmation property. With
model driven, we can add the passwordConfirmation property to our
Action class, but not have to refer to it differently in the server
page.

-- HTH, Ted.
* http://www.husted.com/struts/


On 11/8/06, frankiestd168 <ch...@hotmail.com> wrote:
>
> this is a question for Struts2 interceptors..
>
> I saw some examples, the action class implements ModelDriven,
> <interceptor-ref name="model-driven"/>
>
> So this function is added in action class:
>
> public Object getModel() {
>        return user;
> }
>
> Then jsp can directly access the properties of the User object.
>
> Beside this, what is the benefit of using this interceptor ?
> Is that only for jsp purpose?

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