It's not a secret anymore!*
The moose likes Struts and the fly likes Struts and the core design patterns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts and the core design patterns" Watch "Struts and the core design patterns" New topic
Author

Struts and the core design patterns

Basel Al-Mustafa
Greenhorn

Joined: Nov 27, 2004
Posts: 27
Hi,

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

Regards,

Basel Mahdi
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
I think, Struts frame work is use
- Front Controller pattern
- View Helper pattern
- Dispatcher View pattern


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
gayathri hariharan
Greenhorn

Joined: Jan 11, 2005
Posts: 27
Does it also follow Command pattern by asking us to implement Action's execute method?


thanks,<br />Gayathri
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

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.


[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
gayathri hariharan
Greenhorn

Joined: Jan 11, 2005
Posts: 27
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts and the core design patterns
 
Similar Threads
How to start with Part-2 preparation
Design Patterm Doubt
how many design patterns are there?
Design Patterns.
Kyle - another question