This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Part II: Cade's usage of a Controller within the Class Diagram & the Sequence Diagrams Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Part II: Cade Watch "Part II: Cade New topic
Author

Part II: Cade's usage of a Controller within the Class Diagram & the Sequence Diagrams

Allexicus Kernikus
Ranch Hand

Joined: Oct 07, 2009
Posts: 42
I have noticed a strange usage of Controller objects within Cade's example for Part II & III.

In his exemplary class diagram he uses one central Controller object for all views (JSPs). In his subsequent sequence diagram he uses a NoticeController for his CreateNotice.jsp.

First of all, isn't it advisable to design your system to use one central controller, and each view to use its own model (e.g. a backing bean). I've so far not come across multiple controllers, each for a specific view...

Second, if multiple controllers would be advisable, shouldn't these be denoted in the Class Diagram as well?

- Alex
Dannyf Soon
Ranch Hand

Joined: Oct 07, 2008
Posts: 37
I wanted to ask the same questions as yours.

Ranchers please share your idea on Allexicus's questions.

-Danny


SCEA 5/OCMJEA
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

In JSF< a controller contains logic. It's not like other (mostly older) frameworks which use the controller to delegate to an action. Since there is logic, it makes sense to have multiple controllers for different parts of the app. The class diagram should be consistent with the sequence diagrams though.

I added this to the list of issues with the example in the book.


[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
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Jeanne Boyarsky wrote:In JSF< a controller contains logic. It's not like other (mostly older) frameworks which use the controller to delegate to an action. Since there is logic, it makes sense to have multiple controllers for different parts of the app. The class diagram should be consistent with the sequence diagrams though.

I added this to the list of issues with the example in the book.


Hi Jeanne,

Do you mean managed beans for each JSF page?


SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCEA/OCMJEA 5.0
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

Yes. The managed beans are sometimes referred to as the controller.
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Jeanne Boyarsky wrote:Yes. The managed beans are sometimes referred to as the controller.


Did you add Managed Beans in the Component Diagram as separate components?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

Krzysztof Koziol wrote:
Jeanne Boyarsky wrote:Yes. The managed beans are sometimes referred to as the controller.


Did you add Managed Beans in the Component Diagram as separate components?

Yes. I don't think it should be that way in the real world, but it seemed important to Oracle.
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Jeanne Boyarsky wrote:
Yes. I don't think it should be that way in the real world, but it seemed important to Oracle.


Thanks for this info. Did you somehow show in the Component Diagram that JSPs and Managed Beans are part of JSF framework? Could we use different colors for those components or add <<JSF>> stereotype?

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

Krzysztof Koziol wrote:
Jeanne Boyarsky wrote:
Yes. I don't think it should be that way in the real world, but it seemed important to Oracle.


Thanks for this info. Did you somehow show in the Component Diagram that JSPs and Managed Beans are part of JSF framework? Could we use different colors for those components or add <<JSF>> stereotype?


Grudgingly. I did put JSPs on the component diagram. I said they were JSPs but didn't connect to JSF there.
Nilessh Ganu
Ranch Hand

Joined: Dec 22, 2009
Posts: 100
Jeanne Boyarsky wrote:Yes. The managed beans are sometimes referred to as the controller.

1. Jeanne, I agree JSF managed beans(and JSF validators too ?) are sometimes referred to as controllers, but the naming convention used by Cade's book do not suggests this. For example, BidController might not be the managed bean. It seems like a pure controller.

But I am not sure if we can have different controllers in JSF. As FacesServlet is final and we cannot redirect/delegate to specific controllers.

2. Another question in relation: I am using a JSF custom validator for one of the JSF component, can I show it like this in my sequence diagram:





Nilesh
SCJP SCWCD OCMJEA
Gurukant Desai
Ranch Hand

Joined: Apr 07, 2008
Posts: 56
Hi Nilessh,

1) Even though FacesServlet is final and we can still redirect/delegate to specific controllers on basis of URL pattern configured in FacesServlet. Say /ABC/* will redirect to ABCController.java and /DEF/* will redirect to DEFController.java.

I agree that in Cade's book they have not refered BidController as managed bean, because they have not taken any framework into consideration. But in JSF framework managed bean can do the same work that is done by BidController in Cade's book.

2) I am planning not to show any validator in any of the diagram, in order to be in-sync with Cade's diagrams.

Fellow Ranchers, Please share your opinions on both points!
Nilessh Ganu
Ranch Hand

Joined: Dec 22, 2009
Posts: 100
Sorry Gurukant to reply late.

Gurukant Desai wrote:

1) Even though FacesServlet is final and we can still redirect/delegate to specific controllers on basis of URL pattern configured in FacesServlet. Say /ABC/* will redirect to ABCController.java and /DEF/* will redirect to DEFController.java.


Right, but then we are moving away from having a single centralized controller(Front controller).

I am using JSF validators(flow described in my other post) in sequence diagram and component diagram.
Ranchers, does that sounds good ?
Gurukant Desai
Ranch Hand

Joined: Apr 07, 2008
Posts: 56
Hi Nilessh,

That is fine as per Application Controller J2EE design pattern, A front controller can delegate the request processing to Applicaiton Controller.

FacesServlet of JSF is example of FrontController and Managed beans are Application Controllers.

I have not shown any validators in any of my diagrams (As per example in Cade's book). However there is no harm in showing validators. The detailed the better.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Part II: Cade's usage of a Controller within the Class Diagram & the Sequence Diagrams
 
Similar Threads
Passed SCEA II & III - score 84
PetStore EJBControllerLocalEJB ...Why is it used..
Cade's class and sequence diagram
Regarding UseCase-Class Diagram-Componet-Sequence Diagram
Class diagram for Part II in Mark Cade and Simon Robers's Study Guide