Package freemarker.template

Examples of freemarker.template.TemplateModelException


        {
            throw e;
        }
        catch(Exception e)
        {
            throw new TemplateModelException("get(" + key + ") failed on " +
                "instance of " + object.getClass().getName(), e);
        }
    }
View Full Code Here


            }
            catch(TemplateModelException e) {
                throw e;
            }
            catch(Exception e) {
                throw new TemplateModelException("Could not load taglib information", e);
            }
            return null;
        }
    }
View Full Code Here

    {
        String filePath = tldPath[0];
        TldParser tldParser = new TldParser();
        InputStream in = ctx.getResourceAsStream(filePath);
        if(in == null) {
            throw new TemplateModelException("Could not find webapp resource " + filePath);
        }
        String url = ctx.getResource(filePath).toExternalForm();
        try {
            String jarPath = tldPath[1];
            if(jarPath != null) {
                ZipInputStream zin = new ZipInputStream(in);
                for(;;) {
                    ZipEntry ze = zin.getNextEntry();
                    if(ze == null) {
                        throw new TemplateModelException("Could not find JAR entry " + jarPath + " inside webapp resource " + filePath);
                    }
                    String zname = ze.getName();
                    if(zname.equals(jarPath)) {
                        parseXml(zin, "jar:" + url + "!" + zname, tldParser);
                        break;
                    }
                }
            }
            else {
                parseXml(in, url, tldParser);
            }
        }
        finally {
            in.close();
        }
        EventForwarding eventForwarding = EventForwarding.getInstance(ctx);
        if(eventForwarding != null) {
            eventForwarding.addListeners(tldParser.getListeners());
        }
        else if(tldParser.getListeners().size() > 0) {
            throw new TemplateModelException(
                "Event listeners specified in the TLD could not be " +
                " registered since the web application doesn't have a" +
                " listener of class " + EventForwarding.class.getName() +
                ". To remedy this, add this element to web.xml:\n" +
                "| <listener>\n" +
View Full Code Here

            }
            else {
                return '/' + uri;
            }
        }
        throw new TemplateModelException(
            "Can't resolve relative URI " + uri +
            " as request URL information is unavailable.");
    }
View Full Code Here

            boolean usesAdapter;
            if(out instanceof JspWriter) {
                // This is just a sanity check. If it were JDK 1.4-only,
                // we'd use an assert.
                if(out != pageContext.getOut()) {
                    throw new TemplateModelException(
                        "out != pageContext.getOut(). Out is " +
                        out + " pageContext.getOut() is " +
                        pageContext.getOut());
                }
                usesAdapter = false;
            }
            else {               
                out = new JspWriterAdapter(out);
                pageContext.pushWriter((JspWriter)out);
                usesAdapter = true;
            }
            JspWriter w = new TagWriter(out, tag, pageContext, usesAdapter);
            pageContext.pushTopTag(tag);
            pageContext.pushWriter(w);
            return w;
        }
        catch(TemplateModelException e) {
            throw e;
        }
        catch(RuntimeException e) {
            throw e;
        }
        catch(Exception e) {
            throw new TemplateModelException(e);
        }
    }
View Full Code Here

                            BodyTag btag = (BodyTag)tag;
                            btag.setBodyContent(this);
                            btag.doInitBody();
                        }
                        else {
                            throw new TemplateModelException("Can't buffer body since " + tag.getClass().getName() + " does not implement BodyTag.");
                        }
                        // Intentional fall-through
                    }
                    case Tag.EVAL_BODY_INCLUDE: {
                        return TransformControl.EVALUATE_BODY;
                    }
                    default: {
                        throw new RuntimeException("Illegal return value " + dst + " from " + tag.getClass().getName() + ".doStartTag()");
                    }
                }
            }
            catch(JspException e) {
                throw new TemplateModelException(e.getMessage(), e);
            }
        }
View Full Code Here

                        }
                        case IterationTag.EVAL_BODY_AGAIN: {
                            return REPEAT_EVALUATION;
                        }
                        default: {
                            throw new TemplateModelException("Unexpected return value " + dab + "from " + tag.getClass().getName() + ".doAfterBody()");
                        }
                    }
                }
                endEvaluation();
                return END_EVALUATION;
            }
            catch(JspException e) {
                throw new TemplateModelException(e);
            }
        }
View Full Code Here

        Configuration configuration = createMock(Configuration.class);
        Set<String> names = createMock(Set.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(model.keys()).andThrow(new TemplateModelException());
        expect(template.getConfiguration()).andReturn(configuration);
        expect(configuration.getSharedVariableNames()).andReturn(names);

        try {
            replay(template, model, configuration, names);
View Full Code Here

        TemplateNumberModel model = createMock(TemplateNumberModel.class);
        Template template = createMock(Template.class);
        TemplateHashModel rootDataModel = createMock(TemplateHashModel.class);
        Writer out = createMock(Writer.class);

        expect(model.getAsNumber()).andThrow(new TemplateModelException());
        expect(template.getMacros()).andReturn(new HashMap<String, Macro>());

        replay(template, rootDataModel, out);
        new Environment(template, rootDataModel, out);
View Full Code Here

        Set<String> names = createMock(Set.class);
        Iterator<String> namesIt = createMock(Iterator.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(model.keys()).andThrow(new TemplateModelException());
        expect(template.getConfiguration()).andReturn(configuration);
        expect(configuration.getSharedVariableNames()).andReturn(names);

        replay(template, model, valueModel, configuration, names, namesIt);
        try {
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateModelException

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.