This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 Action Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Struts2 Action Classes" Watch "Struts2 Action Classes" New topic
Author

Struts2 Action Classes

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

One thing I'm not clear on for Struts2 action classes is how many there should be per action. For example, lets assume I have a group of 3 related actions: list a set of records, delete a record, add a record. Should that be setup as one action class or 3? I found tutorials which show how to setup a struts.xml to do it with one action class such as:



But is this a good practice? It seems like its random which command could be considered "execute()". Is it ok to not have an execute command?


My Blog: Down Home Country Coding with Scott Selikoff
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8260

Scott Selikoff wrote:But is this a good practice?


That Depends. Personally, I like to keep CRUD methods together and have a naming convention so I can easily trace the execution flow like so:
CustomerAction -> CustomerLogic -> CustomerDAO -> CustomerTableInDatabase
There's nothing inherently wrong with creating seperate actions for CRUD functions.

Scott Selikoff wrote:
Is it ok to not have an execute command?


Sure. That's a welcome feature in Struts 2 as opposed to Struts 1


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Struts2 Action Classes
 
Similar Threads
Struts2: Test action classes
Struts2 Action Mapping Problem - No configuration found for the specified action
migration to Struts2
struts2 + Json and JQuery.
Display Image using struts2