aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Question for Micheal Yuan and Thomas Heute, Polymorphic Page Navigation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Question for Micheal Yuan and Thomas Heute, Polymorphic Page Navigation" Watch "Question for Micheal Yuan and Thomas Heute, Polymorphic Page Navigation" New topic
Author

Question for Micheal Yuan and Thomas Heute, Polymorphic Page Navigation

James Frankman
Greenhorn

Joined: Jun 01, 2006
Posts: 12
Is there a way to have polymorphic navigation with SEAM? The problem I am having is this:

I have two classes Person and Organization that are subclasses of a superclass Client. With SEAM I perform a search where you submit a name search string and Companies and Persons with that name are returned in the query. I then display a list of persons and companies. When a user clicks a Person record I want them to go to the Person edit page. When a user clicks on an Organization I want them to go to the Organization page. The only two solutions I can think of is to:

1. Use an "instance of" inside my action to determine which page to user should go to
2. Add a method to the Client class named "getPage" and override it in the Person and Company classes. The method would return a page name or value that would be used to navigate to the Person and Client page respectively.

Are there better ways of doing this with SEAM?
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
James,

Using pages.xml, you can specify navigation rules based on the application state (using EL expressions) -- you do not have to deal with the return-string-based JSF navigation rules no more!

cheers
Michael


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
James Frankman
Greenhorn

Joined: Jun 01, 2006
Posts: 12
Do you have any examples?

How would this work for my question? What would you include in the EL expression that would make the user navigate to the person page if he clicked on a person and navigate to the organization page if he clicked on an organization.
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Check out the "hotel booking" example from the book (see link in my signature).

In the event handler method of "person" or "company" click, you figure out what is clicked via "instanceof" and then set a value in a Seam component (maybe the Person.isClicked), then return null. The pages.xml use the EL for that component (e.g., #{person.isClicked}) to determine which pages to go next.
James Frankman
Greenhorn

Joined: Jun 01, 2006
Posts: 12
I will check out your book. I was hoping that I could make this all happen polymorphically without using an "instanceof" but it looks like that is not possible. Thanks.
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
James,

You might be able to get away from instanceof. I just do not know your use cases very well. My point is that you have a lot more flexibility in Seam when it comes to page navigation.

If it does not do what you want, raise a feature request in Seam JIRA and we will be happy to look into it.

cheers
Michael
 
Don't get me started about those stupid light bulbs.
 
subject: Question for Micheal Yuan and Thomas Heute, Polymorphic Page Navigation