Examples of TemplateModel


Examples of com.sencha.gxt.core.rebind.XTemplateParser.TemplateModel

        }
      }

      XTemplateParser p = new XTemplateParser(l.branch(Type.DEBUG,
          "Parsing provided template for " + method.getReadableDeclaration()));
      TemplateModel m = p.parse(template);
      SafeHtmlTemplatesCreator safeHtml = new SafeHtmlTemplatesCreator(context, l.branch(Type.DEBUG,
          "Building SafeHtmlTemplates"), method);

      sw.println(method.getReadableDeclaration(false, true, true, false, true) + "{");
      sw.indent();
View Full Code Here

Examples of com.volantis.xml.pipeline.sax.impl.template.TemplateModel

        XMLPipelineContext pipelineContext =
                dynamicProcess.getPipelineContext();

        // Get the model for containing template for bindings that reference
        // values in containing templates, may be null.
        TemplateModel containing = (TemplateModel) pipelineContext.findObject(
                TemplateModel.class);

        // Create the template process and add it to the pipeline.
        TemplateProcess process = new TemplateProcess(containing);
        dynamicProcess.addProcess(process);

        // Push the template model onto the stack so it can be picked up by
        // nested elements.
        TemplateModel model = process;
        pipelineContext.pushObject(model, false);

        // Start the template.
        model.startTemplate();

        // The presence or absence of the href attribute determines the gross
        // structure of the template:apply.
        String href = attributes.getValue("href");
        EndElementAction action;
        if (href == null) {

            // Template must be inline so a template:bindings element is
            // expected.
            action = new EndTemplateAction(model, process);
        } else {

            // Pretend that we have received a template:bindings element.
            model.startBindings();

            // Template definition needs including at the end
            // of the operation.
            action = new IncludeDefinitionAction(model, process, href);
        }
View Full Code Here

Examples of freemarker.template.TemplateModel

        }
        if(object instanceof TemplateModelAdapter) {
            return ((TemplateModelAdapter)object).getTemplateModel();
        }
        if(useCache && isCacheable(object)) {
            TemplateModel model = lookup(object);
            if(model == null) {
                model = create(object);
                register(model, object);
            }
            return model;
View Full Code Here

Examples of freemarker.template.TemplateModel

        // Set cache policy
        setBrowserCachingPolicy(response);

        ServletContext servletContext = getServletContext();
        try {
            TemplateModel model = createModel(wrapper, servletContext, request, response);

            // Give subclasses a chance to hook into preprocessing
            if (preTemplateProcess(request, response, template, model)) {
                try {
                    // Process the template
View Full Code Here

Examples of freemarker.template.TemplateModel

        unlistedModels.put(key, model);
    }

    public TemplateModel get(String key) throws TemplateModelException {
        // Lookup in page scope
        TemplateModel model = super.get(key);
        if(model != null) {
            return model;
        }

        // Look in unlisted models
View Full Code Here

Examples of freemarker.template.TemplateModel

    public void execute(final Environment env, Map params,
            TemplateModel[] loopVars, TemplateDirectiveBody body)
    throws TemplateException, IOException
    {
        // Determine the path
        final TemplateModel path = (TemplateModel)params.get("path");
        if(path == null) {
            throw new TemplateException("Missing required parameter 'path'", env);
        }
        if(!(path instanceof TemplateScalarModel)) {
            throw new TemplateException("Expected a scalar model. 'path' is instead " +
                    path.getClass().getName(), env);
        }
        final String strPath = ((TemplateScalarModel)path).getAsString();
        if(strPath == null) {
            throw new TemplateException("String value of 'path' parameter is null", env);
        }
       
        // See whether we need to use a custom response (if we're inside a TTM
        // or TDM or macro nested body, we'll need to as then the current
        // FM environment writer is not identical to HTTP servlet response
        // writer.
        final Writer envOut = env.getOut();
        final HttpServletResponse wrappedResponse;
        if(envOut == response.getWriter()) {
            // Don't bother wrapping if environment's writer is same as
            // response writer
            wrappedResponse = response;
        }
        else {
            final PrintWriter printWriter = (envOut instanceof PrintWriter) ?
                (PrintWriter)envOut :
                new PrintWriter(envOut);
            // Otherwise, create a response wrapper that will pass the
            // env writer, potentially first wrapping it in a print
            // writer when it ain't one already.
            wrappedResponse = new HttpServletResponseWrapper(response) {
                public PrintWriter getWriter() {
                    return printWriter;
                }
            };
        }

        // Determine inherit_params value
        final boolean inheritParams;
        final TemplateModel inheritParamsModel = (TemplateModel)params.get("inherit_params");
        if(inheritParamsModel == null) {
            // defaults to true when not specified
            inheritParams = true;
        }
        else {
            if(!(inheritParamsModel instanceof TemplateBooleanModel)) {
                throw new TemplateException("'inherit_params' should be a boolean but it is " +
                        inheritParamsModel.getClass().getName() + " instead", env);
            }
            inheritParams = ((TemplateBooleanModel)inheritParamsModel).getAsBoolean();
        }
       
        // Get explicit params, if any
        final TemplateModel paramsModel = (TemplateModel)params.get("params");
       
        // Determine whether we need to wrap the request
        final HttpServletRequest wrappedRequest;
        if(paramsModel == null && inheritParams) {
            // Inherit original request params & no params explicitly
View Full Code Here

Examples of freemarker.template.TemplateModel

   
    protected FreeMarkerPageContext() throws TemplateModelException
    {
        environment = Environment.getCurrentEnvironment();

        TemplateModel appModel = environment.getGlobalVariable(
                FreemarkerServlet.KEY_APPLICATION_PRIVATE);
        if(!(appModel instanceof ServletContextHashModel)) {
            appModel = environment.getGlobalVariable(
                    FreemarkerServlet.KEY_APPLICATION);
        }
        if(appModel instanceof ServletContextHashModel) {
            this.servlet = ((ServletContextHashModel)appModel).getServlet();
        }
        else {
            throw new  TemplateModelException("Could not find an instance of " +
                    ServletContextHashModel.class.getName() +
                    " in the data model under either the name " +
                    FreemarkerServlet.KEY_APPLICATION_PRIVATE + " or " +
                    FreemarkerServlet.KEY_APPLICATION);
        }
       
        TemplateModel requestModel =
            environment.getGlobalVariable(FreemarkerServlet.KEY_REQUEST_PRIVATE);
        if(!(requestModel instanceof HttpRequestHashModel)) {
            requestModel = environment.getGlobalVariable(
                    FreemarkerServlet.KEY_REQUEST);
        }
View Full Code Here

Examples of freemarker.template.TemplateModel

    public Object getAttribute(String name, int scope)
    {
        switch (scope) {
            case PAGE_SCOPE: {
                try {
                    TemplateModel m = environment.getGlobalNamespace().get(name);
                    if (m instanceof AdapterTemplateModel) {
                        return ((AdapterTemplateModel) m).getAdaptedObject(OBJECT_CLASS);
                    }
                    if (m instanceof WrapperTemplateModel) {
                        return ((WrapperTemplateModel)m).getWrappedObject();
View Full Code Here

Examples of freemarker.template.TemplateModel

abstract class SequenceBuiltins {
    abstract static class SequenceBuiltIn extends BuiltIn {
        TemplateModel _getAsTemplateModel(Environment env)
                throws TemplateException
        {
            TemplateModel model = target.getAsTemplateModel(env);
            if (!(model instanceof TemplateSequenceModel)) {
                throw invalidTypeException(model, target, env, "sequence");
            }
            return calculateResult((TemplateSequenceModel) model);
        }
View Full Code Here

Examples of freemarker.template.TemplateModel

            // Copy the Seq into a Java List[KVP] (also detects key type at the 1st item):
            int keyType = KEY_TYPE_NOT_YET_DETECTED;
            Comparator keyComparator = null;
            for (int i = 0; i < ln; i++) {
                TemplateModel item = seq.get(i);
               
                Object key = item;
                for (int keyNameI = 0; keyNameI < keyNamesLn; keyNameI++) {
                    try {
                        key = ((TemplateHashModel) key).get(keyNames[keyNameI]);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.