Splash › Forums › PrettyFaces Users › Build url programmatically and redirect from ajax action
Tagged: michael kors o, ray ban, ray bans
This topic contains 3 replies, has 2 voices, and was last updated by detestable 4 years, 3 months ago.
I’d like to redirect the user after an ajax request, I could do something like :
FacesContext ctx = FacesContext.getCurrentInstance();
ExternalContext extContext = ctx.getExternalContext();
But I’d like to use pretty faces mapping to resolve the url from a string like :
“/WEB-INF/index.xhtml?parameter=test” (that would resolve to /ctx/index/test)
may be by building the url programmatically.
How could one achieve this?
You could simply return the following string from the action method invoked by the AJAX request:
PrettyFaces will intercept that and rewrite the URL to the pretty one.
You could also use ExternalContext.encodeActionURL() to get the pretty URL:
String url = externalContext.encodeActionURL("/WEB-INF/index.xhtml?parameter=test");
Thank you very much Christian for your assistance,
Using encodeActionURL in combination with FacesContext.getCurrentInstance().getExternalContext().redirect works perfectly fine.
You must be logged in to reply to this topic.
Comments are closed.
If you find our tools useful, please consider making a donation to help us stay online and building software!