Permalink
Browse files

Add Faces#getRenderKit()

  • Loading branch information...
1 parent d364daf commit efd93475aa4f9cdd19dc9a8c33f3c7e3283820f1 @BalusC BalusC committed Sep 11, 2015
Showing with 30 additions and 0 deletions.
  1. +17 −0 src/main/java/org/omnifaces/util/Faces.java
  2. +13 −0 src/main/java/org/omnifaces/util/FacesLocal.java
@@ -45,6 +45,7 @@
import javax.faces.context.Flash;
import javax.faces.context.PartialViewContext;
import javax.faces.event.PhaseId;
+import javax.faces.render.RenderKit;
import javax.faces.view.ViewDeclarationLanguage;
import javax.faces.view.ViewMetadata;
import javax.faces.view.facelets.FaceletContext;
@@ -464,6 +465,22 @@ public static ViewDeclarationLanguage getViewDeclarationLanguage() {
}
/**
+ * Returns the {@link RenderKit} associated with the "current" view ID or view handler.
+ * <p>
+ * The current view ID is the view ID that's set for the view root that's associated with the current faces context.
+ * Or if there is none, then the current view handler will be assumed, which is the view handler that's associated
+ * with the requested view.
+ *
+ * @return The {@link RenderKit} associated with the "current" view ID or view handler.
+ * @since 2.2
+ * @see UIViewRoot#getRenderKitId()
+ * @see ViewHandler#calculateRenderKitId(FacesContext)
+ */
+ public static RenderKit getRenderKit() {
+ return FacesLocal.getRenderKit(getContext());
+ }
+
+ /**
* Normalize the given path as a valid view ID based on the current mapping, if necessary.
* <ul>
* <li>If the current mapping is a prefix mapping and the given path starts with it, then remove it.
@@ -40,6 +40,7 @@
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.ValueExpression;
+import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.ProjectStage;
import javax.faces.application.ViewHandler;
@@ -49,6 +50,8 @@
import javax.faces.context.FacesContext;
import javax.faces.context.Flash;
import javax.faces.event.PhaseId;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
import javax.faces.view.ViewDeclarationLanguage;
import javax.faces.view.ViewMetadata;
import javax.faces.view.facelets.FaceletContext;
@@ -258,6 +261,16 @@ public static ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext co
/**
* {@inheritDoc}
+ * @see Faces#getRenderKit()
+ */
+ public static RenderKit getRenderKit(FacesContext context) {
+ UIViewRoot view = context.getViewRoot();
+ String renderKitId = (view != null) ? view.getRenderKitId() : context.getApplication().getViewHandler().calculateRenderKitId(context);
+ return ((RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY)).getRenderKit(context, renderKitId);
+ }
+
+ /**
+ * {@inheritDoc}
* @see Faces#normalizeViewId(String)
*/
public static String normalizeViewId(FacesContext context, String path) {

0 comments on commit efd9347

Please sign in to comment.