i have a jsf application and i want hide the url and keep just the name of application in URL while swiching between pages .
thats the url that i have :
As MaVRoSCy said you can use Prettyfaces to rewrite your URLs. Their docs are very useful and very clear. Here are steps to follow (without Maven dependencies approach):
1) Download latest jar depending on your JSF version and put it in your project classpath.
2) Add following to web.xml
Pretty Filter
com.ocpsoft.pretty.PrettyFilter
Pretty Filter
/*
FORWARD
REQUEST
ERROR
3) Create under WEB-INF
a file: pretty-config.xml
that will define your prettyfaces mappings, like this one:
4) Now when defining outcome
in your managed beans, you should return pretty:idOfURLMapping
. For example: pretty:accueil
will redirect to the first defined page above and normally it would display http://localhost:8080/PlanificationDrapageWeb/
as URL.
Finally, notice that you should use this only if it's a functional requirement. Otherwise I would use URLs without extensions as BalusC mentioned (his method or if you want advanced Prettyfaces functionalities).
EDIT
It seems that Prettyfaces does not work for this situation. Sorry for your time wasting.
Now I would suggest another possible solution, since BalusC's answer was deleted.
1) You create a new managed bean of session scope, let's call it: PageManagedBean
:
public class PageManagedBean {
private String includedPage = "/pages/accueil.xhtml";
//Setters and getters
}
2) Create a master layout page (Facelets templating):
Now when you want to change page, you just change PageManagedBean.includedPage value.