我对 p:menuItem 有这个问题 - 使用 PF 3.3.1、PrettyFaces 3.3.3 和 JSF/Mojarra2.1。
所以我有一组 p:menuItems 需要从当前页面传递一个“ID”参数。但是,我不希望构建以下形式的 URL:/page/targetPage?id=id&faces-redirect=true。我想做的是,在页面操作处理程序上,重定向到有问题的 URL。但是,问题是生成的重定向将 windowId 附加到末尾,我无法访问 targetURL!
在我的小脸上:
<p:menuitem action="#{myActions.performAction}" ajax="false" value="navigateToThisAction"/>
在我的支持 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;
}