• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question for Micheal Yuan and Thomas Heute, Polymorphic Page Navigation

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
James Frankman
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic