GeeCON Prague 2014*
The moose likes Struts and the fly likes Extendings Struts Action (creating a custom Action class) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Extendings Struts Action (creating a custom Action class)" Watch "Extendings Struts Action (creating a custom Action class)" New topic
Author

Extendings Struts Action (creating a custom Action class)

DN Debed
Greenhorn

Joined: Nov 03, 2008
Posts: 10
I'm thinking of extending the struts Action class to create a custom Action class that my application will use to extend. This is because my application contains attributes (objects) that are stored in the servlet and would be used by most action classes.

Below would be a draft of my custom Action class



Then, all my action classes would extend CustomAction. Such as my example below.



The advantage that I see is that:
1. Other actions does not need to always write to get a servlet attribute. They can just call .
2. I can easily change the name of the servlet attribute in my custom action class and not worry about changing my other action classes that is using this attribute.

So far this is what I have in mind. I would like to know if my idea is okay (what problems/limitations might arise if I use this approach).

Thank you
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Sure, that will work fine--it's a very common technique.
 
GeeCON Prague 2014
 
subject: Extendings Struts Action (creating a custom Action class)