Identifying path of current JSF / XHTML page [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-24 10:42:02

问题


I need something that will uniquely identify my JSF (XHTML) page.

I know that I have:

String URI = servletRequest.getRequestURI();

This gives my full path, but that doesn't help if I use PrettyFaces or any other URL changing library.


回答1:


You can use UIViewRoot#getViewId() for this:

String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();

It's also available in EL as follows:

#{view.viewId}


来源:https://stackoverflow.com/questions/12371100/identifying-path-of-current-jsf-xhtml-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!