You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cheng Wei Lee <zh...@gmail.com> on 2008/03/04 18:58:57 UTC

Struts 2: Creating custom JavaBeans from request parameters (not in action class)

I know I can get the values of the request parameters in the action class
and then use them to instantiate an object. Read from the API for
ParameterAware interface, "One common use for this is to have the action
propagate parameters to internally instantiated data objects.". Does this
means that Struts 2 can do it for us if we implement some interfaces or use
some interceptors? That is, I don't need to create the object in my own
action class?

Re: Struts 2: Creating custom JavaBeans from request parameters (not in action class)

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Cheng Wei Lee wrote:
> I know I can get the values of the request parameters in the action class
> and then use them to instantiate an object. Read from the API for
> ParameterAware interface, "One common use for this is to have the action
> propagate parameters to internally instantiated data objects.". Does this
> means that Struts 2 can do it for us if we implement some interfaces or use
> some interceptors? That is, I don't need to create the object in my own
> action class?
>
>   

If your bean is available in a public property of your action, and has a 
no-arg constructor, Struts 2 will instantiate it and set properties on it.
Ensure you have a getter and setter for the bean in your action.

ParameterAware is rarely needed.



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