• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Action, Business, Form - Independence

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am somewhat new to struts. Please let me know whether the following way of accessing the Objects are fine with.
I have an TestAction.
In the that, I call the TestBusiness
public TestAction()
{
public void execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
TestForm formObj = (TestForm)form;
TestBusiness testBusi = new TestBusiness(formObj);
// Store the ref of form in the Business itself.

testBusi.setFirstSetOfValues();

With the help of the form values that obtained I make somethign on the Action and then
testBusi.setSecondSetOfValues();

All these method calls to the business will set some values in the form.
And inturn they are also making use of some values in teh form.

i.e. Instead of sending those values one by one from the Action to the business, I have taken the form to teh Businesss.

Is this OK to take the ref of Form in the Business class and directly get or set the values from that .

Please let me know whether this way of designing is a good practise or not.
Thanks a lot.

}
}
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dhamodharan,
It would be better to have your business layer return a value object. The action could take the fields from that value object and set them in the form. You want to isolate your business layer from the front end technology. That way if you change your front end, it only affects the front end.
 
Dhamodharan Krishnan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your quick reply.
I will take care of that as you said.
I understood it better now.
Dhamo.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic