@Override
  public void setUp() throws Exception {
    FactoryFinder.releaseFactories();
    super.setUp();
    for (int i = 0, len = FACTORIES.length; i < len; i++) {
      System.getProperties().remove(FACTORIES[i][0]);
    }

    FactoryFinder.releaseFactories();
    int len, i = 0;

    // simulate the "faces implementation specific" part
    for (i = 0, len = FACTORIES.length; i < len; i++) {
      FactoryFinder.setFactory(FACTORIES[i][0], FACTORIES[i][1]);
    }

    UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null);
    root.setViewId("/viewId");
    facesContext.setViewRoot(root);
    RenderKitFactory renderKitFactory =
        (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
    RenderKit renderKit = new MockRenderKit();
    try {
      renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
    } catch (IllegalArgumentException e) {;
    }
  }
Beispiel #2
0
  /**
   * In the absence of webapp faces-config.xml and META-INF/services, verify that the overrides
   * specified in the implementation faces-config.xml take precedence.
   *
   * @throws java.lang.Exception
   */
  public void testJSFImplCase() throws Exception {
    Object factory = null;
    Class clazz = null;

    FactoryFinder.releaseFactories();
    int len, i = 0;

    // this testcase only simulates the "faces implementation
    // specific" part
    for (i = 0, len = FactoryFinderTestCase2.FACTORIES.length; i < len; i++) {
      FactoryFinder.setFactory(
          FactoryFinderTestCase2.FACTORIES[i][0], FactoryFinderTestCase2.FACTORIES[i][1]);
    }

    for (i = 0, len = FactoryFinderTestCase2.FACTORIES.length; i < len; i++) {
      clazz = Class.forName(FactoryFinderTestCase2.FACTORIES[i][0]);
      factory = FactoryFinder.getFactory(FactoryFinderTestCase2.FACTORIES[i][0]);
      assertTrue(
          "Factory for " + clazz.getName() + " not of expected type.",
          clazz.isAssignableFrom(factory.getClass()));
      clazz = Class.forName(FactoryFinderTestCase2.FACTORIES[i][1]);
      assertTrue(
          "Factory " + FactoryFinderTestCase2.FACTORIES[i][1] + " not of expected type",
          clazz.isAssignableFrom(factory.getClass()));
    }
  }
  @Override
  public void init(ServletConfig servletConfig) throws ServletException {
    this.servletConfig = servletConfig;

    facesContextFactory =
        (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
    LifecycleFactory lifecycleFactory =
        (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
  }
  public BridgePhaseBaseImpl(PortletConfig portletConfig, BridgeConfig bridgeConfig) {

    this.portletConfig = portletConfig;
    this.bridgeConfig = bridgeConfig;
    this.portletName = portletConfig.getPortletName();
    this.bridgeRequestScopePreserved =
        PortletConfigParam.BridgeRequestScopePreserved.getBooleanValue(portletConfig);

    this.portletContext =
        BridgePortletContextFactory.getPortletContextInstance(portletConfig.getPortletContext());

    // Initialize the incongruity context implementation.
    this.incongruityContext = IncongruityContextFactory.getIncongruityContextInstance();

    // Get the bridge request scope cache from the factory.
    this.bridgeRequestScopeCache =
        BridgeRequestScopeCacheFactory.getBridgeRequestScopeCacheInstance(portletContext);

    // Get the default lifecycle instance from the factory.
    LifecycleFactory lifecycleFactory =
        (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    String lifecycleId = this.portletContext.getInitParameter(Bridge.LIFECYCLE_ID);

    if (lifecycleId == null) {
      lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
    }

    this.facesLifecycle = lifecycleFactory.getLifecycle(lifecycleId);
  }
Beispiel #5
0
  /**
   * Obtain and return the {@link ResponseStateManager} for the specified #renderKitId.
   *
   * @param context the {@link FacesContext} of the current request
   * @param renderKitId {@link RenderKit} ID
   * @return the {@link ResponseStateManager} for the specified #renderKitId
   * @throws FacesException if an exception occurs while trying to obtain the <code>
   *     ResponseStateManager</code>
   */
  public static ResponseStateManager getResponseStateManager(
      FacesContext context, String renderKitId) throws FacesException {

    assert (null != renderKitId);
    assert (null != context);

    RenderKit renderKit = context.getRenderKit();
    if (renderKit == null) {
      // check request scope for a RenderKitFactory implementation
      RenderKitFactory factory =
          (RenderKitFactory)
              RequestStateManager.get(context, RequestStateManager.RENDER_KIT_IMPL_REQ);
      if (factory != null) {
        renderKit = factory.getRenderKit(context, renderKitId);
      } else {
        factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
        if (factory == null) {
          throw new IllegalStateException();
        } else {
          RequestStateManager.set(context, RequestStateManager.RENDER_KIT_IMPL_REQ, factory);
        }
        renderKit = factory.getRenderKit(context, renderKitId);
      }
    }
    return renderKit.getResponseStateManager();
  }
 public FacesContextImpl(ExternalContext ec, Lifecycle lifecycle) {
   Util.notNull("ec", ec);
   Util.notNull("lifecycle", lifecycle);
   this.externalContext = ec;
   setCurrentInstance(this);
   DEFAULT_FACES_CONTEXT.set(this);
   rkFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
 }
Beispiel #7
0
 // Tear down instance variables required by ths test case
 @Override
 public void tearDown() throws Exception {
   super.tearDown();
   FactoryFinder.releaseFactories();
   for (int i = 0, len = FactoryFinderTestCase2.FACTORIES.length; i < len; i++) {
     System.getProperties().remove(FactoryFinderTestCase2.FACTORIES[i][0]);
   }
 }
Beispiel #8
0
  private void restoreView(FacesContext context) throws FacesException {
    Application app = context.getApplication();

    if (app instanceof ApplicationImpl) ((ApplicationImpl) app).initRequest();

    ViewHandler view = app.getViewHandler();

    view.initView(context);

    UIViewRoot viewRoot = context.getViewRoot();

    if (viewRoot != null) {
      ExternalContext extContext = context.getExternalContext();

      viewRoot.setLocale(extContext.getRequestLocale());

      doSetBindings(context.getELContext(), viewRoot);

      return;
    }

    String viewId = calculateViewId(context);

    String renderKitId = view.calculateRenderKitId(context);

    RenderKitFactory renderKitFactory =
        (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);

    RenderKit renderKit = renderKitFactory.getRenderKit(context, renderKitId);

    ResponseStateManager stateManager = renderKit.getResponseStateManager();

    if (stateManager.isPostback(context)) {
      viewRoot = view.restoreView(context, viewId);

      if (viewRoot != null) {
        doSetBindings(context.getELContext(), viewRoot);
      } else {
        // XXX: backward compat issues with ViewHandler and StateManager

        // throw new ViewExpiredException(L.l("{0} is an expired view", viewId));

        context.renderResponse();

        viewRoot = view.createView(context, viewId);

        context.setViewRoot(viewRoot);
      }

      context.setViewRoot(viewRoot);
    } else {
      context.renderResponse();

      viewRoot = view.createView(context, viewId);

      context.setViewRoot(viewRoot);
    }
  }
  protected FacesContextFactory getFacesContextFactory() {

    if (facesContextFactory == null) {
      facesContextFactory =
          (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
    }

    return facesContextFactory;
  }
Beispiel #10
0
  public void registerELResolverAndListenerWithJsp(ServletContext context, boolean reloaded) {

    if (webConfig.isSet(WebContextInitParameter.ExpressionFactory) || !isJspTwoOne(context)) {

      // first try to load a factory defined in web.xml
      if (!installExpressionFactory(
          context, webConfig.getOptionValue(WebContextInitParameter.ExpressionFactory))) {

        throw new ConfigurationException(
            MessageUtils.getExceptionMessageString(
                MessageUtils.INCORRECT_JSP_VERSION_ID,
                WebContextInitParameter.ExpressionFactory.getDefaultValue(),
                WebContextInitParameter.ExpressionFactory.getQualifiedName()));
      }

    } else {

      // JSP 2.1 specific check
      if (JspFactory.getDefaultFactory().getJspApplicationContext(context) == null) {
        return;
      }

      // register an empty resolver for now. It will be populated after the
      // first request is serviced.
      FacesCompositeELResolver compositeELResolverForJsp =
          new ChainTypeCompositeELResolver(FacesCompositeELResolver.ELResolverChainType.JSP);
      ApplicationAssociate associate = ApplicationAssociate.getInstance(context);
      if (associate != null) {
        associate.setFacesELResolverForJsp(compositeELResolverForJsp);
      }

      // get JspApplicationContext.
      JspApplicationContext jspAppContext =
          JspFactory.getDefaultFactory().getJspApplicationContext(context);

      // cache the ExpressionFactory instance in ApplicationAssociate
      if (associate != null) {
        associate.setExpressionFactory(jspAppContext.getExpressionFactory());
      }

      // register compositeELResolver with JSP
      try {
        jspAppContext.addELResolver(compositeELResolverForJsp);
      } catch (IllegalStateException e) {
        ApplicationFactory factory =
            (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
        Application app = factory.getApplication();
        if (app.getProjectStage() != ProjectStage.UnitTest && !reloaded) {
          throw e;
        }
      }

      // register JSF ELContextListenerImpl with Jsp
      ELContextListenerImpl elContextListener = new ELContextListenerImpl();
      jspAppContext.addELContextListener(elContextListener);
    }
  }
Beispiel #11
0
 /**
  * Calls through to {@link javax.faces.FactoryFinder#releaseFactories()} ignoring any exceptions.
  */
 private void releaseFactories() {
   try {
     FactoryFinder.releaseFactories();
   } catch (FacesException ignored) {
     if (LOGGER.isLoggable(Level.FINE)) {
       LOGGER.log(Level.FINE, "Exception thrown from FactoryFinder.releaseFactories()", ignored);
     }
   }
 }
Beispiel #12
0
 protected static Application getApplication() {
   FacesContext context = FacesContext.getCurrentInstance();
   if (context != null) {
     return (FacesContext.getCurrentInstance().getApplication());
   }
   ApplicationFactory afactory =
       (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
   return (afactory.getApplication());
 }
Beispiel #13
0
  public MultiViewHandler() {

    WebConfiguration config = WebConfiguration.getInstance();
    String defaultSuffixConfig =
        config.getOptionValue(WebConfiguration.WebContextInitParameter.DefaultSuffix);
    configuredExtensions = Util.split(defaultSuffixConfig, " ");
    pdlFactory =
        (PageDeclarationLanguageFactory)
            FactoryFinder.getFactory(FactoryFinder.PAGE_DECLARATION_LANGUAGE_FACTORY);
  }
Beispiel #14
0
  /**
   * Acquire the factory instances we will require.
   *
   * @throws ServletException if, for any reason, the startup of this Faces application failed. This
   *     includes errors in the config file that is parsed before or during the processing of this
   *     <code>init()</code> method.
   */
  public void init(ServletConfig servletConfig) throws ServletException {

    // Save our ServletConfig instance
    this.servletConfig = servletConfig;

    // Acquire our FacesContextFactory instance
    try {
      facesContextFactory =
          (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
    } catch (FacesException e) {
      ResourceBundle rb = LOGGER.getResourceBundle();
      String msg = rb.getString("severe.webapp.facesservlet.init_failed");
      Throwable rootCause = (e.getCause() != null) ? e.getCause() : e;
      LOGGER.log(Level.SEVERE, msg, rootCause);
      throw new UnavailableException(msg);
    }

    // Acquire our Lifecycle instance
    try {
      LifecycleFactory lifecycleFactory =
          (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
      String lifecycleId;

      // First look in the servlet init-param set
      if (null == (lifecycleId = servletConfig.getInitParameter(LIFECYCLE_ID_ATTR))) {
        // If not found, look in the context-param set
        lifecycleId = servletConfig.getServletContext().getInitParameter(LIFECYCLE_ID_ATTR);
      }

      if (lifecycleId == null) {
        lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
      }
      lifecycle = lifecycleFactory.getLifecycle(lifecycleId);
      initHttpMethodValidityVerification();
    } catch (FacesException e) {
      Throwable rootCause = e.getCause();
      if (rootCause == null) {
        throw e;
      } else {
        throw new ServletException(e.getMessage(), rootCause);
      }
    }
  }
  protected synchronized Lifecycle getFacesLifecycle() {
    if (lifecycle == null) {
      // Acquire our Lifecycle instance
      LifecycleFactory lifecycleFactory =
          (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
      lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
    }

    return lifecycle;
  }
Beispiel #16
0
 //
 // Methods from TestCase
 //
 public void setUp() {
   super.setUp();
   ApplicationFactory aFactory =
       (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
   application = aFactory.getApplication();
   UIViewRoot viewRoot =
       Util.getViewHandler(getFacesContext()).createView(getFacesContext(), null);
   viewRoot.setViewId("viewId");
   viewRoot.setLocale(Locale.US);
   getFacesContext().setViewRoot(viewRoot);
 }
  public void contextDestroyed(ServletContextEvent sce) {
    ServletContext context = sce.getServletContext();
    InitFacesContext initContext = null;
    try {
      initContext = getInitFacesContext(context);
      if (null == initContext) {
        initContext = new InitFacesContext(context);
      }

      if (webAppListener != null) {
        webAppListener.contextDestroyed(sce);
        webAppListener = null;
      }
      if (webResourcePool != null) {
        webResourcePool.shutdownNow();
      }
      if (!ConfigManager.getInstance().hasBeenInitialized(context)) {
        return;
      }
      GroovyHelper helper = GroovyHelper.getCurrentInstance(context);
      if (helper != null) {
        helper.setClassLoader();
      }
      if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(
            Level.FINE, "ConfigureListener.contextDestroyed({0})", context.getServletContextName());
      }

      ELContext elctx = new ELContextImpl(initContext.getApplication().getELResolver());
      elctx.putContext(FacesContext.class, initContext);
      initContext.setELContext(elctx);
      Application app = initContext.getApplication();
      app.publishEvent(initContext, PreDestroyApplicationEvent.class, Application.class, app);

      Util.setNonFacesContextApplicationMap(null);

    } catch (Exception e) {
      if (LOGGER.isLoggable(Level.SEVERE)) {
        LOGGER.log(
            Level.SEVERE,
            "Unexpected exception when attempting to tear down the Mojarra runtime",
            e);
      }
    } finally {
      ApplicationAssociate.clearInstance(context);
      ApplicationAssociate.setCurrentInstance(null);
      // Release the initialization mark on this web application
      ConfigManager.getInstance().destroy(context);
      FactoryFinder.releaseFactories();
      ReflectionUtils.clearCache(Thread.currentThread().getContextClassLoader());
      WebConfiguration.clear(context);
      InitFacesContext.cleanupInitMaps(context);
    }
  }
Beispiel #18
0
  public Application getApplication() {
    checkReleased();

    if (application == null) {
      ApplicationFactory aFactory =
          (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
      this.application = aFactory.getApplication();
    }

    return this.application;
  }
Beispiel #19
0
  private static ELResolver _getELResolver(FacesContext context) {
    // First try the FacesContext, which is a faster way to
    // get the ELResolver (and the 99.9% scenario)
    if (context != null) return context.getApplication().getELResolver();

    // If that fails, then we're likely outside of the JSF lifecycle.
    // Look to the ApplicationFactory.
    ApplicationFactory factory =
        (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    return factory.getApplication().getELResolver();
  }
Beispiel #20
0
  public MultiViewHandler() {

    WebConfiguration config = WebConfiguration.getInstance();

    configuredExtensions =
        config.getOptionValue(WebConfiguration.WebContextInitParameter.DefaultSuffix, " ");
    extensionsSet = config.isSet(WebConfiguration.WebContextInitParameter.DefaultSuffix);
    vdlFactory =
        (ViewDeclarationLanguageFactory)
            FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY);
  }
  /** @see javax.faces.context.FacesContext#getPartialViewContext() */
  public PartialViewContext getPartialViewContext() {

    assertNotReleased();
    if (partialViewContext == null) {
      PartialViewContextFactory f =
          (PartialViewContextFactory)
              FactoryFinder.getFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY);
      partialViewContext = f.getPartialViewContext(this);
    }
    return partialViewContext;
  }
 /** @see javax.faces.context.FacesContext#getApplication() */
 public Application getApplication() {
   assertNotReleased();
   if (null != application) {
     return application;
   }
   ApplicationFactory aFactory =
       (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
   application = aFactory.getApplication();
   assert (null != application);
   return application;
 }
 protected void initializeJSF() {
   // Make sure the faces application is set:
   {
     ApplicationFactory f =
         (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
     Application a = f.getApplication();
     if (!(a instanceof SystemApplication)) {
       Application b = new SystemApplication(a);
       f.setApplication(b);
     }
   }
 }
Beispiel #24
0
 public String getFactoryPrintout() {
   String result = "";
   String[] factoryNames = {
     FactoryFinder.APPLICATION_FACTORY,
     FactoryFinder.FACES_CONTEXT_FACTORY,
     FactoryFinder.LIFECYCLE_FACTORY,
     FactoryFinder.RENDER_KIT_FACTORY
   };
   for (int i = 0; i < factoryNames.length; i++) {
     String tmp = FactoryFinder.getFactory(factoryNames[i]).toString();
     if (tmp.startsWith("com.sun.faces")) {
       int idx = tmp.lastIndexOf('.');
       tmp = tmp.substring(idx + 1);
       idx = tmp.indexOf('@');
       tmp = tmp.substring(0, idx);
       result += tmp + ' ';
     } else {
       result += FactoryFinder.getFactory(factoryNames[i]).toString() + ' ';
     }
   }
   return result;
 }
Beispiel #25
0
  protected FaceletFactory createFaceletFactory(Compiler c, WebConfiguration webConfig) {

    // refresh period
    String refreshPeriod = webConfig.getOptionValue(FaceletsDefaultRefreshPeriod);
    long period = Long.parseLong(refreshPeriod);

    // resource resolver
    ResourceResolver resolver = new DefaultResourceResolver();
    String resolverName = webConfig.getOptionValue(FaceletsResourceResolver);
    if (resolverName != null && resolverName.length() > 0) {
      resolver =
          (ResourceResolver)
              ReflectionUtil.decorateInstance(resolverName, ResourceResolver.class, resolver);
    }

    FaceletCache cache = null;
    String faceletCacheName = webConfig.getOptionValue(FaceletCache);
    if (faceletCacheName != null && faceletCacheName.length() > 0) {
      try {
        com.sun.faces.facelets.FaceletCache privateApiCache =
            (com.sun.faces.facelets.FaceletCache)
                ReflectionUtil.forName(faceletCacheName).newInstance();
        cache = new PrivateApiFaceletCacheAdapter(privateApiCache);
      } catch (Exception e) {
        if (LOGGER.isLoggable(Level.SEVERE)) {
          LOGGER.log(Level.SEVERE, "Error Loading Facelet cache: " + faceletCacheName, e);
        }
      }
    }
    if (null == cache) {
      FaceletCacheFactory cacheFactory =
          (FaceletCacheFactory) FactoryFinder.getFactory(FactoryFinder.FACELET_CACHE_FACTORY);
      cache = cacheFactory.getFaceletCache();
    }

    // Resource.getResourceUrl(ctx,"/")
    FaceletFactory factory = new DefaultFaceletFactory(c, resolver, period, cache);

    // Check to see if a custom Factory has been defined
    String factoryClass = webConfig.getOptionValue(FaceletFactory);
    if (factoryClass != null && factoryClass.length() > 0) {
      factory =
          (FaceletFactory)
              ReflectionUtil.decorateInstance(factoryClass, FaceletFactory.class, factory);
    }

    return factory;
  }
Beispiel #26
0
  public RenderKit getRenderKit() {
    checkReleased();

    UIViewRoot viewRoot = getViewRoot();
    if (viewRoot == null) {
      return null;
    }

    String renderKitId = viewRoot.getRenderKitId();
    if (renderKitId == null) {
      return null;
    } else {
      RenderKitFactory rkFactory =
          (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
      return rkFactory.getRenderKit(this, renderKitId);
    }
  }
  /**
   * Jsf dispatch page.
   *
   * @param fctx the faces context
   * @param page the pge
   */
  private void jsfDispatchPage(FacesContext fctx, String page) {
    LifecycleFactory lf =
        (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    Lifecycle lifecycle = lf.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
    ViewHandler vh = fctx.getApplication().getViewHandler();
    fctx.getViewRoot().setRenderKitId(vh.calculateRenderKitId(fctx));
    fctx.setViewRoot(vh.createView(fctx, page));

    // view rendering
    try {
      lifecycle.render(fctx);
    } catch (Exception e) {
      LOG.log(Level.INFO, "Error while rendering page. Attempting again" + page, e);
      lifecycle.render(fctx);
    } finally {
      fctx.release();
    }
  }
  /**
   * This test verifies that if the variable resolver does not find a managed bean it tries to
   * instantiate it if it was added to the application's managed bean factory list.
   */
  public void testManagedBean() throws Exception {
    String beanName = "com.sun.faces.TestBean";

    ManagedBeanInfo beanInfo =
        new ManagedBeanInfo(beanName, beanName, "session", null, null, null, null);

    ApplicationFactory aFactory =
        (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    ApplicationImpl application = (ApplicationImpl) aFactory.getApplication();
    ApplicationAssociate associate = ApplicationAssociate.getCurrentInstance();
    BeanManager manager = associate.getBeanManager();
    manager.register(beanInfo);

    VariableResolver variableResolver = application.getVariableResolver();

    Object result = variableResolver.resolveVariable(getFacesContext(), beanName);

    assertTrue(result instanceof TestBean);
  }
Beispiel #29
0
 /**
  * This constructor uses the current <code>Application</code> instance to obtain the navigation
  * mappings used to make navigational decisions.
  */
 public NavigationHandlerImpl() {
   super();
   if (logger.isLoggable(Level.FINE)) {
     logger.log(Level.FINE, "Created NavigationHandler instance ");
   }
   // if the user is using the decorator pattern, this would cause
   // our ApplicationAssociate to be created, if it isn't already
   // created.
   ApplicationFactory aFactory =
       (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
   aFactory.getApplication();
   ApplicationAssociate associate =
       ApplicationAssociate.getInstance(FacesContext.getCurrentInstance().getExternalContext());
   if (associate != null) {
     caseListMap = associate.getNavigationCaseListMappings();
     wildCardSet = associate.getNavigationWildCardList();
     navigationConfigured = (wildCardSet != null && caseListMap != null);
     development = associate.isDevModeEnabled();
   }
 }
Beispiel #30
0
  @Override
  public void applyNextHandler(FaceletContext ctx, UIComponent c)
      throws IOException, FacesException, ELException {

    // attributes need to be applied before any action is taken on
    // nested children handlers or the composite component handlers
    // as there may be an expression evaluated at tree creation time
    // that needs access to these attributes
    setAttributes(ctx, c);

    // Allow any nested elements that reside inside the markup element
    // for this tag to get applied
    super.applyNextHandler(ctx, c);

    // Apply the facelet for this composite component
    applyCompositeComponent(ctx, c);

    // Allow any PDL declared attached objects to be retargeted
    if (ComponentHandler.isNew(c)) {
      FacesContext context = ctx.getFacesContext();
      String viewId = context.getViewRoot().getViewId();
      // PENDING(rlubke): performance
      ViewDeclarationLanguageFactory factory =
          (ViewDeclarationLanguageFactory)
              FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY);

      ViewDeclarationLanguage vdl = factory.getViewDeclarationLanguage(viewId);
      vdl.retargetAttachedObjects(context, c, getAttachedObjectHandlers(c, false));
      vdl.retargetMethodExpressions(context, c);

      // RELEASE_PENDING This is *ugly*.  See my comments in
      // ComponentTagHandlerDelegateImpl at the end of the apply()
      // method
      if (StateContext.getStateContext(context).partialStateSaving(context, viewId)) {
        markInitialState(c);
      }
    }
  }