views:

424

answers:

2

For example, I have class Article with methods getTitle () and getContent ().

I also have ArticlesService with method getAllArticles (). How to create a list of links with meaningful names (formed with #{article.title})? Like:

http://mysiteaddress.com/article/first-article-title
http://mysiteaddress.com/article/how-to-make-links-in-jsf

..or something similar.

I can create links with all necessary functionality with <h:commandLink>, but I don't know how to make nice 'href' for it: it always has href '#'.

I can create nice links with <h:outputLink> but I don't know how to add necessary functionality to it.


In jsp I created my own front-controller, which parsed urls from requests and then performed redirection to correspondent jsp-page.

How to achieve the same functionality in JSF?

+1  A: 

If this is intended as an improvement of an existing application, then you basically need a PhaseListener and/or a Filter which detects "dirty" URL's and redirect the request to a "friendly" URL and when it detects "friendly" URL, it should forward the request to the "dirty" URL.

If this is a new application or an application which is open to changes, you could consider the PrettyUrlPhaseListener of the Mojarra Scales.

BalusC
+2  A: 
cetnar