public static String getResourceURL(FacesContext context, String value) { if (LangUtils.isValueBlank(value)) { return Constants.EMPTY_STRING; } else if (value.contains(ResourceHandler.RESOURCE_IDENTIFIER)) { return value; } else { String url = context.getApplication().getViewHandler().getResourceURL(context, value); return context.getExternalContext().encodeResourceURL(url); } }
/** * Builds the view if not already available. This is mostly required for ViewExpiredException's. * * @param context The {@link FacesContext}. * @param throwable The occurred {@link Throwable}. * @param rootCause The root cause. * @return The unwrapped {@link Throwable}. * @throws java.io.IOException If building the view fails. */ protected Throwable buildView(FacesContext context, Throwable throwable, Throwable rootCause) throws IOException { if (context.getViewRoot() == null) { ViewHandler viewHandler = context.getApplication().getViewHandler(); String viewId = viewHandler.deriveViewId(context, ComponentUtils.calculateViewId(context)); ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, viewId); UIViewRoot viewRoot = vdl.createView(context, viewId); context.setViewRoot(viewRoot); vdl.buildView(context, viewRoot); // Workaround for Mojarra // if UIViewRoot == null -> 'IllegalArgumentException' is throwed instead of 'ViewExpiredException' if (rootCause == null && throwable instanceof IllegalArgumentException) { rootCause = new javax.faces.application.ViewExpiredException(viewId); } } return rootCause; }
/** * Gets the current ViewHandler via FacesContext.getApplication().getViewHandler(). * We have to use this method to invoke any other specified ViewHandler-method * in the code, because direct access (this.method()) will cause problems if * the ViewHandler is wrapped. * @param facesContext * @return */ public static ViewHandler getViewHandler(FacesContext facesContext) { return facesContext.getApplication().getViewHandler(); }
private static String getAction(FacesContext facesContext) { String viewId = facesContext.getViewRoot().getViewId(); String actionURL = facesContext.getApplication().getViewHandler(). getActionURL(facesContext, viewId); return (facesContext.getExternalContext().encodeActionURL(actionURL)); } }
private String getEncodedResourceURL(FacesContext facesContext, ResourceHandler resourceHandler, Application application, String resourceURL) { String encodedResourceURL = resourceURL; if (!isEncodedResourceURL(resourceHandler, encodedResourceURL)) { ViewHandler viewHandler = application.getViewHandler(); resourceURL = viewHandler.getResourceURL(facesContext, resourceURL); ExternalContext externalContext = facesContext.getExternalContext(); encodedResourceURL = externalContext.encodeResourceURL(resourceURL); } return encodedResourceURL; } }
Map<String, String> requestParams = context.getExternalContext().getRequestParameterMap(); NavigationCase navCase = getNavigationCase(context, fromAction, dialogOutcome); String toViewId = navCase.getToViewId(context); String url = context.getApplication().getViewHandler().getBookmarkableURL(context, toViewId, params, includeViewParams); url = EscapeUtils.forJavaScript(url);
@Deprecated public static Locale getLocale(final FacesContext facesContext) { final UIViewRoot root = facesContext.getViewRoot(); final Locale locale; if (root != null) { locale = root.getLocale(); } else { locale = facesContext.getApplication().getViewHandler().calculateLocale(facesContext); } return locale; }
/** * @param context FacesContext for the response we are creating * * @return Return the value to be rendered as the <code>action</code> attribute * of the form generated for this component. */ private static String getActionStr(FacesContext context) { String viewId = context.getViewRoot().getViewId(); String actionURL = context.getApplication().getViewHandler(). getActionURL(context, viewId); return (context.getExternalContext().encodeActionURL(actionURL)); }
private String getEncodedResourceURL(FacesContext facesContext, ResourceHandler resourceHandler, Application application, String name) { String encodedResourceURL = name; if (!isFacesResourceURL(resourceHandler, name)) { ViewHandler viewHandler = application.getViewHandler(); String resourceURL = viewHandler.getResourceURL(facesContext, name); ExternalContext externalContext = facesContext.getExternalContext(); encodedResourceURL = externalContext.encodeResourceURL(resourceURL); } return encodedResourceURL; }
/** * Proceed to render the Page. */ protected void render(FacesContext context, Page page) { UIViewRoot viewRoot = context.getApplication().getViewHandler() .createView( context, getViewId(page) ); context.setViewRoot(viewRoot); }
url = "#".equals(href) ? "#" : context.getExternalContext().encodeRedirectURL(href, outcomeTarget.getParams()); && outcomeTarget.isDisableClientWindow()) { clientWindow = context.getExternalContext().getClientWindow(); url = context.getApplication().getViewHandler().getBookmarkableURL(context, toViewId, params, isIncludeViewParams);
public boolean execute(FacesContext facesContext) { Application application = facesContext.getApplication(); ViewHandler viewHandler = application.getViewHandler(); try { viewHandler.renderView(facesContext, facesContext.getViewRoot()); } catch (IOException e) { throw new FacesException(e.getMessage(), e); } return false; }
/** * @param context FacesContext for the response we are creating * * @return Return the value to be rendered as the <code>action</code> attribute * of the form generated for this component. */ private static String getActionStr(FacesContext context) { String viewId = context.getViewRoot().getViewId(); String actionURL = context.getApplication().getViewHandler(). getActionURL(context, viewId); return (context.getExternalContext().encodeActionURL(actionURL)); }
private String getEncodedResourceURL(FacesContext facesContext, ResourceHandler resourceHandler, Application application, String name) { String encodedResourceURL = name; if (!isFacesResourceURL(resourceHandler, name)) { ViewHandler viewHandler = application.getViewHandler(); String resourceURL = viewHandler.getResourceURL(facesContext, name); ExternalContext externalContext = facesContext.getExternalContext(); encodedResourceURL = externalContext.encodeResourceURL(resourceURL); } return encodedResourceURL; }
public static String resolveResourceURL(FacesContext facesContext, String path) { ExternalContext ec = facesContext.getExternalContext(); String ctxtPath = ec.getRequestContextPath(); if (path.length() > 0 && path.charAt(0) == '/' && path.startsWith(ctxtPath)) { path = path.substring(ctxtPath.length()); } return facesContext.getApplication().getViewHandler().getResourceURL(facesContext, path); }
/** * @param facesContext * @return String A String representing the action URL */ protected String getActionUrl(FacesContext facesContext) { ViewHandler viewHandler = facesContext.getApplication().getViewHandler(); String viewId = facesContext.getViewRoot().getViewId(); return viewHandler.getActionURL(facesContext, viewId); }
protected String getActionURL(FacesContext facesContext) { String actionURL = facesContext.getApplication().getViewHandler().getActionURL(facesContext, facesContext.getViewRoot().getViewId()); return facesContext.getExternalContext().encodeActionURL(actionURL); }
public static String resolveResourceURL(FacesContext facesContext, String path) { ExternalContext ec = facesContext.getExternalContext(); String ctxtPath = ec.getRequestContextPath(); //ICE-6063: Strip the context path off if it's there because the ViewHandler no //longer includes that bit of logic. if (path.charAt(0) == '/' && path.startsWith(ctxtPath)) { path = path.substring(ctxtPath.length()); } return facesContext.getApplication().getViewHandler().getResourceURL(facesContext, path); }
/** * @param facesContext * @return String A String representing the action URL */ protected String getActionUrl(FacesContext facesContext) { ViewHandler viewHandler = facesContext.getApplication().getViewHandler(); String viewId = facesContext.getViewRoot().getViewId(); return viewHandler.getActionURL(facesContext, viewId); }
/** * @param context FacesContext for the response we are creating * * @return Return the value to be rendered as the <code>action</code> attribute * of the form generated for this component. */ private static String getActionStr(FacesContext context) { String viewId = context.getViewRoot().getViewId(); String actionURL = context.getApplication().getViewHandler(). getActionURL(context, viewId); return (context.getExternalContext().encodeActionURL(actionURL)); }