I have an url: example.com/mypage how can I make jsf page based on mypage value? Is it somehow possible to get it from FaceletsContext?
Only way how to do it which I thought is by creating a filter and parsing uri, but it must be very very wrong:
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
String uri = request.getRequestURI();
if (uri == null || uri.length() == 0 || uri.equals("/") || !uri.contains("/") || uri.contains("xhtml")) {
chain.doFilter(request, response);
return;
}
List<String> parts = new ArrayList<String>(Arrays.asList(uri.split("/")));
parts.remove("");
if (parts.size() != 1) {
chain.doFilter(request, response);
return;
}
forwardTo(request, response, "page.xhtml?value=" + parts.get(0));
}