I have this issue with p:menuItem - using PF 3.3.1, PrettyFaces 3.3.3 and JSF/Mojarra2.1.
So I have a set of p:menuItems that need to pass through an "ID" parameter from the current page. However, I do not wish to build a URL of the form: /page/targetPage?id=id&faces-redirect=true. What I would like to do is, on the page action handler, redirect to the URL in question. However, the problem is that the resulting redirect attaches a windowId to the end and I cannot access the targetURL!
in my facelet:
<p:menuitem action="#{myActions.performAction}" ajax="false" value="navigateToThisAction"/>
In my backing bean:
public String performAction() {
return navigate("pretty:myAction");
}
protected String navigate(String mappingId) {
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
PrettyContext context = PrettyContext.getCurrentInstance(request);
PrettyURLBuilder builder = new PrettyURLBuilder();
UrlMapping mapping = context.getConfig().getMappingById(mappingId);
String targetURL = builder.build(mapping, true, getId());
try {
FacesContext.getCurrentInstance().getExternalContext().redirect(targetURL);
} catch (IOException ioe) {
System.out.println("Error redirecting..." + ioe.getMessage());
}
return null;
}
windowId=<something>
manually in your browser do you still get the 404 error? – Luiggi MendozatargetURL
value before it is send to the redirect? – Luiggi Mendoza