Dariusz Wojtas wrote:
>
> Want to have a bean separate from the action and just reference it?
> Define your bean (whatever you want) and just declare it as a variable
> on your action.
> Nothing more.
> Add getter and setter.
>
> class MyAction ... {
> private MyBeanClass myBean;
>
> }
>
> in your JSP just prefix bean components with the bean name;
>
> <s:textfield name="myBean.title" ... />
>
> That's all :)
>
> Dariusz Wojtas
>
>
One other thing that's nice about Struts2/WW is that you can utilize the
ModelDriven interface on your action.
So your action is
public class MyAction implements ModelDriven {
private MyBean myBean = new MyBean();
public Object getModel() { return myBean; }
}
that way your form fields can still be referenced by
<s:textfield name="title" />
Also very useful when moving your properties from the action into a
model/domain object/value object/etc... because your front-end code does not
hae to change.
--
View this message in context:
http://www.nabble.com/-S2--How-to-separate-Action-from-%22FormBean%22-tf2936107.html#a8222113
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]