aspose file tools
The moose likes Struts and the fly likes Struts 1 - Refactoring actions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Reply 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: 26496
    
  78

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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Struts 1 - Refactoring actions
 
Similar Threads
neither action class called nor jsp page displayed
problem with submit and redirection {javascipt struts under google chrome}
how to define functionality for 2 buttons in an action form
isCancelled(request) not invoked
problem with LookupDispatchAction