tags:

views:

530

answers:

1

I am working on struts2 application. I have getter/setter in my action class. Now, I am sending object of my action class (say Action.java) to DAO class (say Dao.java) as a parameter of some method. All is ruuning well, I am getting value of all getters in my Dao.java. Now, I want to do all this without creating and sending the object of Action.java to Dao.java. Simply asking, is it possible to get action class- getter methods value in Dao.java without passing the object of Action.java ?

Please suggest.

+2  A: 

Why do you want to do something like that?

I suppose you are populating action fields from html form and than using this Action as a data transfer object to DAO. This is not very good design imho.

If you are searching for cleaner solution you would be better if you use ModelDriven action. Your action will implement interface ModelDriven<YourModel> where YourModel will contain all data fields. Struts2 will automatically populate fields from the html form to YourModel. Then you can pass YourModel to DAO.

rdk