struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From foramp <>
Subject Re: Separate Java Bean Class for Getter/Setter method.
Date Wed, 11 May 2011 10:06:18 GMT

If you want to keep the bean in a separate class then your action class that
needs to implement two interfaces Modeldriven and Preparable. Its called
model driven approach in struts 2

class MyBean
// attributes
// getter and setter

class MyAction extends ActionSupport implements ModelDrive, Preparable

MyBean myBean;

public Object getModel()
return myBean;

public void prepare()
myBean = new MyBean();



This is beautifully explained in the book Struts 2 black book on page 
number 435. please find at

arin_12 wrote:
> I am trying to develop a small struts apps. I want to write all the setter
> and getter method in a separate Bean file and want to keep the controller
> clean :) If we remem, struts 1.2 style. 
> I dont want to use viewname.elementname style. This create a issue in the
> javascript validation. As JS is not able to recognize the "." dot. 
> <s:textfield id="alName" name="objAllergyView.alName"/>
> <s:textfield id="alDescription" name="objAllergyView.alDescription"/>
> Thanks,

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message