• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts and the core design patterns

 
Basel Al-Mustafa
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Are the web tire design patterns discussed in the 'Core J2EE Patterns' book implemented by Struts?

Regards,

Basel Mahdi
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, Struts frame work is use
- Front Controller pattern
- View Helper pattern
- Dispatcher View pattern
 
gayathri hariharan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it also follow Command pattern by asking us to implement Action's execute method?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gayathri,
While the action has an execute method, it isn't really the command pattern. Take a look at this article for more details on the command pattern.
 
gayathri hariharan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jeanne,

Thanks for the article. It's been just a few months since i got into patterns and stuff.so please bare with me. This is the code i found in the article.



Just my guess that Struts processor class might look like code below.
But to me it appears that the code snippet in the article has more delegation than may be struts but otherwise it does look like command pattern to me.
I mean as per code below, may be the processor knows about the receiver but it still looks quite decoupled. So whether i save a html form or try to fetch some data, i still need not know what methods action class has. I just need to call execute on that method.

Looks like i'm missing something here.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gayathri,
The key with the command pattern is that you set the parameters as instance variables using setters. There is then a no-arg (zero argument) execute method.

If a Struts action looked like this, it would be the command pattern:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic