• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do you link from entities to detail pages?  RSS feed

 
Hubert Grzeskowiak
Greenhorn
Posts: 22
Java Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

so far I'm only showing lists of items. Now I have created a detail page which should show one particular entity. The detail page has a view param that is the name of the entity. The URL is something like .../detail/application.xhtml?name=FooBar It all works so far.

Now I'm wondering whether I'll have to generate that URL by hand every time I want to use it or does JSF give me any shortcut? In Django (Python) for example, you name your views and the URL is generated for you based on the view name.

Thanks in advance
Hugo
 
Hubert Grzeskowiak
Greenhorn
Posts: 22
Java Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Current status:



I don't like the fact I have a part of the URL in the link. When I change the path of the file one day all links are broken.
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In normal operation, JSF does not use URL parameters. It handles such things entirely on the server side by navigating between Views referencing backing beans. In fact, JSF is rather infamous in that the URL displayed in the browser menubar often references some other page than the one being displayed. JSF uses URLs more as a "session handle" than as an absolute resource locator.

There are times when you want to jump directly to a given JSF page, passing in information from external sources (URL parameters). A prime example of this is a "bookmarkable URL", which can be saved in the client's browser as a "favorite". JSF version 2 has some support for this, but there's also a JSF support add-on called PrettyFaces that can help out as well.

Nevertheless, putting parameters on URLs should not be done as a matter of course. You might as well be using a hammer to drive screws if you do that. And that brings up another important point: JSF is an architecture designed to work with POJOs and injection (Inversion of Control). So the more JSF-specific code that you put in your JSF code, the more likely you're not using JSF effectively.
 
Hubert Grzeskowiak
Greenhorn
Posts: 22
Java Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim and thanks for the answer,
navigating or showing different content based on backing beans is an anti-pattern IMHO. I know JSF is a resource and component based framework, but that doesn't mean we have to ignore the request incl. URL entirely. Bookmarkable URLs and the ability of page refreshing are basic essentials for SEO and UX. I found out this misguided JSF philosophy somewhat too late, and I guess I'll be rather using request based frameworks like Spring MVC for new projects when possible.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!