• 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

validate() for multiple actions

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I've recently started looking into Struts2 and am learning it by building a simple CRUD web application. Compared to Struts1.x, I like the improvements in Struts 2.x, where I can have the same Action class for all operations for my entity. What I mean is, Struts 1.x forced me to have one Action class for each of the CRUD operations of my entity - since execute() method was the only method in the action class, that'd be, well, executed. With Struts2, I can create just one Action class, and implement different methods, one for each of the CRUD operations. Based on how I map them in my struts.xml, the framework will call the specific method for the action I'm invoking. This, coupled with, wildcard action mapping allows to be very concise in struts.xml.




But, when I read about the validate() method in the Action class, I couldn't find a way to have a custom validate() method for each of the action. Needless to say, the inputs for each of the actions is going to be different, and thus the validation also will be different. But, I have only one validate() method. Does this mean that I have to do an if/else on the action name in the validate() method?
I've searched Struts FAQs and this forum but couldn't find any relevant information. I'd appreciate it someone can shed some light on this.
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I don't have an answer regarding validation, but would just like to point out that even in Struts 1.x, it was possible to have single Action with method per operation, using DispatchAction
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic