01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: EngineTemplateInitializer.java 3810 2007-06-25 13:36:58Z gbevin $
07: */
08: package com.uwyn.rife.engine;
09:
10: import com.uwyn.rife.template.Template;
11: import com.uwyn.rife.template.TemplateInitializer;
12:
13: public class EngineTemplateInitializer implements TemplateInitializer {
14: public void initialize(Template template) {
15: // Obtain the element that's active in the current running thread and
16: // obtain its context. It's not possible to store the element context
17: // in the initializer since that wouldn't work with continuations.
18: ElementSupport element = ElementContext
19: .getActiveElementSupport();
20: if (null == element) {
21: return;
22: }
23:
24: // check for a valid element context
25: ElementContext context = element._getElementContext();
26: if (null == context) {
27: return;
28: }
29:
30: // set an element expression var
31: template.setExpressionVar("element", element);
32:
33: // process the early embedded elements
34: context.processEmbeddedElementsEarly(template, element);
35: }
36: }
|