@Override public ViewDeclarationLanguage getViewDeclarationLanguage(String viewId) { ViewDeclarationLanguage wrappedViewDeclarationLanguage = getWrappedHack().getViewDeclarationLanguage(viewId); boolean facelets = wrappedViewDeclarationLanguage.getClass().toString().toLowerCase().contains("facelet"); ViewDeclarationLanguage viewDeclarationLanguage; if (facelets) { viewDeclarationLanguage = wrappedViewDeclarationLanguage; } else { ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); String initParam = externalContext.getInitParameter(Bridge.RENDER_POLICY); // If the developer has specified ALWAYS_DELEGATE in the WEB-INF/web.xml descriptor, then execute // the Mojarra/MyFaces ViewDeclarationLanguage. if (BridgeRenderPolicy.ALWAYS_DELEGATE.toString().equals(initParam)) { viewDeclarationLanguage = wrappedViewDeclarationLanguage; } // Otherwise, if the developer specified NEVER_DELEGATE or didn't specify a value, then execute the // bridge's JSP ViewDeclarationLanguage implementation. Note that the spec indicates that if the // developer doesn't specify a value, then the bridge first delegates to Mojarra/MyFaces but then // tries its own JSP ViewDeclarationLanguage if an exception is thrown. This is non-performant // because Mojarra/MyFaces will always throw the exception. This bridge implementation avoids this // expensive operation because ViewDeclarationLanguageJspImpl wraps the Mojarra/MyFaces // implementation in such a way that Mojarra/MyFaces can execute without throwing an exception. else { viewDeclarationLanguage = new ViewDeclarationLanguageJspImpl(wrappedViewDeclarationLanguage); } } return viewDeclarationLanguage; }
if (policy != null) mRenderPolicy = Bridge.BridgeRenderPolicy.valueOf(policy);
@Override public ViewDeclarationLanguage getViewDeclarationLanguage(String viewId) { ViewDeclarationLanguage wrappedViewDeclarationLanguage = getWrappedHack().getViewDeclarationLanguage(viewId); boolean facelets = wrappedViewDeclarationLanguage.getClass().toString().toLowerCase().contains("facelet"); ViewDeclarationLanguage viewDeclarationLanguage; if (facelets) { viewDeclarationLanguage = wrappedViewDeclarationLanguage; } else { ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); String initParam = externalContext.getInitParameter(Bridge.RENDER_POLICY); // If the developer has specified ALWAYS_DELEGATE in the WEB-INF/web.xml descriptor, then execute // the Mojarra/MyFaces ViewDeclarationLanguage. if (BridgeRenderPolicy.ALWAYS_DELEGATE.toString().equals(initParam)) { viewDeclarationLanguage = wrappedViewDeclarationLanguage; } // Otherwise, if the developer specified NEVER_DELEGATE or didn't specify a value, then execute the // bridge's JSP ViewDeclarationLanguage implementation. Note that the spec indicates that if the // developer doesn't specify a value, then the bridge first delegates to Mojarra/MyFaces but then // tries its own JSP ViewDeclarationLanguage if an exception is thrown. This is non-performant // because Mojarra/MyFaces will always throw the exception. This bridge implementation avoids this // expensive operation because ViewDeclarationLanguageJspImpl wraps the Mojarra/MyFaces // implementation in such a way that Mojarra/MyFaces can execute without throwing an exception. else { viewDeclarationLanguage = new ViewDeclarationLanguageJspImpl(wrappedViewDeclarationLanguage); } } return viewDeclarationLanguage; }