• 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

Quick question about getters and setters in Struts 2

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working on a web project in struts 2. I have many actions, and each action has getters and setters to send/bring form values from request. Since many of my forms are similar, more often than not, I end up using same getters and setters but in several places.
I want to know how I can minimize redundant code in my application. Can the actions use something like an EJB that every action can share? or how else can I tackle this? Please help me!!! and if you know the answer please share an example
Thanks in advance!!!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Possibilities include using a base class, creating a base object with the repeated properties and using that in combination with action-specific properties, or using ModelDriven and a model (which could have a base class w/ shared properties) and extending it in the action with action-specific properties.

I'm sure there are other solutions too; those are the ones that popped immediately into my head.

Whether or not getters/setters fall under the category of "repeated code" is a little fuzzy for me, since it's basically non-code, usually automatically generated, and completely ignorable.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic