EngineTemplateInitializer.java :  » Web-Framework » rife-1.6.1 » com » uwyn » rife » engine » Java Open Source

Java Open Source » Web Framework » rife 1.6.1 
rife 1.6.1 » com » uwyn » rife » engine » EngineTemplateInitializer.java
/*
 * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
 * Distributed under the terms of either:
 * - the common development and distribution license (CDDL), v1.0; or
 * - the GNU Lesser General Public License, v2.1 or later
 * $Id: EngineTemplateInitializer.java 3810 2007-06-25 13:36:58Z gbevin $
 */
package com.uwyn.rife.engine;

import com.uwyn.rife.template.Template;
import com.uwyn.rife.template.TemplateInitializer;

public class EngineTemplateInitializer implements TemplateInitializer
{
  public void initialize(Template template)
  {
    // Obtain the element that's active in the current running thread and
    // obtain its context. It's not possible to store the element context
    // in the initializer since that wouldn't work with continuations.
    ElementSupport element = ElementContext.getActiveElementSupport();
    if (null == element)
    {
      return;
    }

    // check for a valid element context
    ElementContext context = element._getElementContext();
    if (null == context)
    {
      return;
    }
    
    // set an element expression var
    template.setExpressionVar("element", element);

    // process the early embedded elements
    context.processEmbeddedElementsEarly(template, element);
  }
}

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.