Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1 - Refactoring actions

 
Ivan Pazmino
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what DispatchAction (and its brethren) are for.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic