File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts 1 - Refactoring actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1 - Refactoring actions" Watch "Struts 1 - Refactoring actions" New topic
Author

Struts 1 - Refactoring actions

Ivan Pazmino
Greenhorn

Joined: Mar 24, 2010
Posts: 6
Hi,

I'm trying to refactor some classes in a project that uses Struts 1. The big problem here is the Action class holds one big if that resolves the forwarding according to the button which has been pressed. This class extends the Action class and overrides the execute method to return the ActionForward.

The first approach is to make at least a method for each button, but still I have a 5 - 6 options if. I'm kind of new to this framework, so I'm sure I can use your suggestions for a better refactoring process.

Thanks in advance.


http://about.me/iapazmino
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

Ivan,
Welcome to JavaRanch!

Can you refactor just the forward part by moving it to a different class that the action calls?

It's hard to provide comments on how to refactor a class without seeing it.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

This is what DispatchAction (and its brethren) are for.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 1 - Refactoring actions
 
Similar Threads
neither action class called nor jsp page displayed
problem with LookupDispatchAction
how to define functionality for 2 buttons in an action form
isCancelled(request) not invoked
problem with submit and redirection {javascipt struts under google chrome}