Package freemarker.template

Examples of freemarker.template.SimpleHash$SynchronizedHash


        }

        ActionInvocation ai = ActionContext.getContext().getActionInvocation();

        Object action = (ai == null) ? null : ai.getAction();
        SimpleHash model = freemarkerManager.buildTemplateModel(stack, action, servletContext, req, res, config.getObjectWrapper());

        model.put("tag", templateContext.getTag());
        model.put("themeProperties", getThemeProps(templateContext.getTemplate()));

        // the BodyContent JSP writer doesn't like it when FM flushes automatically --
        // so let's just not do it (it will be flushed eventually anyway)
        Writer writer = templateContext.getWriter();
        if (bodyContent != null && bodyContent.isAssignableFrom(writer.getClass())) {
View Full Code Here


     * @exception Exception, a generic exception.
     */
    public void doBuild( RunData data )
        throws Exception
    {
         SimpleHash context = getContext(data);

        // First, generate the screen and put it in the context so we
        // can grab it the layout template.
        ConcreteElement results = ScreenLoader.getInstance()
            .eval(data, data.getScreen());
        String screenValue = "";
        if (results != null)
        {
            screenValue = results.toString();
        }
        context.put("screen_placeholder", new SimpleScalar(screenValue));

        // Variable to reference the navigation templates in the
        // layout template.
        context.put("navigation", new NavigationModel(data));

        // Grab the layout template set in the WebMacroSitePage.  If
        // null, then use the default layout template ( done by the
        // TemplateInfo object ).
        String templateName = data.getTemplateInfo().getLayoutTemplate();
View Full Code Here

    public void render_directly() throws Exception {
        getEngine("templateService", createFactory("services.xml"));
        assertProperty("default_encoding", "GBK");
        assertProperty("output_encoding", "UTF-8");

        SimpleHash ctx = new SimpleHash();
        ctx.put("world", "����");

        String content;

        // freemarkerEngine.mergeTemplate(): String
        content = freemarkerEngine.mergeTemplate("test_render.ftl", ctx, "GBK");
        assertContent(content);

        // Specific input charset encoding
        ctx.put("world", new String("����".getBytes("GBK"), "ISO-8859-1")); // hack value
        content = freemarkerEngine.mergeTemplate("test_render.ftl", ctx, "ISO-8859-1");
        content = new String(content.getBytes("ISO-8859-1"), "GBK");
        assertContent(content);

        // freemarkerEngine.mergeTemplate(OutputStream)
View Full Code Here

        HttpServletResponse response = context.getResponse();

        BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
        WrappingTemplateModel.setDefaultObjectWrapper(wrapper);
        Map contextMap = new HashMap();
        SimpleHash root = new SimpleHash(wrapper);
        try {
            Object[] keys = context.getKeys();
            for (int i = 0; i < keys.length; i++) {
                String key = (String) keys[i];
                Object value = context.get(key);
                if (value != null) {
                    contextMap.put(key, value);
                    //no longer wrapping; let FM do it if needed, more efficient
                    //root.put(key, wrapper.wrap(value));
                    root.put(key, value);
                }
            }
            root.put("context", wrapper.wrap(contextMap));
            root.put("cachedInclude", new JpCacheIncludeTransform()); // only adding this in for JP!
            //root.put("jpublishContext", wrapper.wrap(context));
            FreeMarkerViewHandler.prepOfbizRoot(root, request, response);
        } catch (Exception e) {
            throw new ViewRenderException(e);
        }
View Full Code Here

        }

        ActionInvocation ai = ActionContext.getContext().getActionInvocation();

        Object action = (ai == null) ? null : ai.getAction();
        SimpleHash model = freemarkerManager.buildTemplateModel(stack, action, servletContext, req, res, config.getObjectWrapper());

        model.put("tag", templateContext.getTag());
        model.put("themeProperties", getThemeProps(templateContext.getTemplate()));

        // the BodyContent JSP writer doesn't like it when FM flushes automatically --
        // so let's just not do it (it will be flushed eventually anyway)
        Writer writer = templateContext.getWriter();
        if (bodyContent != null && bodyContent.isAssignableFrom(writer.getClass())) {
View Full Code Here

     * @exception Exception, a generic exception.
     */
    public void doBuild(RunData data)
        throws Exception
    {
         SimpleHash context = getContext(data);

        // First, generate the screen and put it in the context so we
        // can grab it the layout template.
        ConcreteElement results = ScreenLoader.getInstance()
            .eval(data, data.getScreen());
        String screenValue = "";
        if (results != null)
        {
            screenValue = results.toString();
        }
        context.put("screen_placeholder", new SimpleScalar(screenValue));

        // Variable to reference the navigation templates in the
        // layout template.
        context.put("navigation", new NavigationModel(data));

        // Grab the layout template set in the WebMacroSitePage.  If
        // null, then use the default layout template ( done by the
        // TemplateInfo object ).
        String templateName = data.getTemplateInfo().getLayoutTemplate();
View Full Code Here

    protected SimpleHash getContext(RunData data)
    {
        // Attempt to get it from the TemplateInfo first.  If it
        // doesn't exist, create it and then stuff it into the
        // TemplateInfo.
        SimpleHash context = (SimpleHash)data.getTemplateInfo()
            .getTemplateContext(FreeMarkerService.CONTEXT);
        if (context == null)
        {
            FreeMarkerService fm = (FreeMarkerService)TurbineServices
                .getInstance().getService(FreeMarkerService.SERVICE_NAME);
View Full Code Here

     * @exception Exception, a generic exception.
     */
    public ConcreteElement buildTemplate(RunData data)
        throws Exception
    {
        SimpleHash context = getContext(data);
        String templateName = TurbineTemplate.getScreenTemplateName(
            data.getTemplateInfo().getScreenTemplate() );

        // Template service adds the leading slash, but make it sure.
        if ((templateName.length() > 0) &&
View Full Code Here

        }

        ActionInvocation ai = ActionContext.getContext().getActionInvocation();

        Object action = (ai == null) ? null : ai.getAction();
        SimpleHash model = freemarkerManager.buildTemplateModel(stack, action, servletContext, req, res, config.getObjectWrapper());

        model.put("tag", templateContext.getTag());
        model.put("themeProperties", getThemeProps(templateContext.getTemplate()));

        // the BodyContent JSP writer doesn't like it when FM flushes automatically --
        // so let's just not do it (it will be flushed eventually anyway)
        Writer writer = templateContext.getWriter();
        final Writer wrapped = writer;
View Full Code Here

            // get the configuration and template
            Configuration config = freemarkerManager.getConfiguration(servletContext);
            Template template = config.getTemplate(decorator.getPage(), getLocale(ctx.getActionInvocation(), config)); // WW-1181

            // get the main hash
            SimpleHash model = freemarkerManager.buildTemplateModel(ctx.getValueStack(), null, servletContext, req, res, config.getObjectWrapper());

            // populate the hash with the page
            model.put("page", page);
            if (page instanceof HTMLPage) {
                HTMLPage htmlPage = ((HTMLPage) page);
                model.put("head", htmlPage.getHead());
            }
            model.put("title",page.getTitle());
            model.put("body",page.getBody());
            model.put("page.properties", new SimpleHash(page.getProperties()));

            // finally, render it
            template.process(model, res.getWriter());
        } catch (Exception e) {
            String msg = "Error applying decorator: " + e.getMessage();
View Full Code Here

TOP

Related Classes of freemarker.template.SimpleHash$SynchronizedHash

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.