Package freemarker.template

Examples of freemarker.template.ObjectWrapper.wrap()


        Environment env = Environment.getCurrentEnvironment();
        TemplateModel nullModel = null;
        if(env != null) {
            ObjectWrapper wrapper = env.getObjectWrapper();
            if(wrapper != null) {
                nullModel = wrapper.wrap(null);
            }
        }
        return unwrap(model, nullModel, permissive);
    }
View Full Code Here


        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(template.getObjectWrapper()).andReturn(objectWrapper);
        expect(objectWrapper.wrap("value")).andReturn(valueModel);

        replay(template, model, valueModel, configuration, objectWrapper);
        Environment env = new Environment(template, model, writer);
        EnvironmentScopeExtractor extractor = new EnvironmentScopeExtractor(env);
        extractor.setValue("key", "value");
View Full Code Here

        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(template.getObjectWrapper()).andReturn(objectWrapper);
        expect(objectWrapper.wrap("value")).andThrow(new TemplateModelException());

        replay(template, model, valueModel, configuration, objectWrapper);
        try {
            Environment env = new Environment(template, model, writer);
            EnvironmentScopeExtractor extractor = new EnvironmentScopeExtractor(env);
View Full Code Here

        Class clazz = this.clazz != null ? this.clazz : object.getClass();
        Configuration configuration = createConfiguration(object, clazz);
        final ObjectWrapper wrapper = configuration.getObjectWrapper();
        configuration.setObjectWrapper(new ObjectWrapper() {
            public TemplateModel wrap(Object obj) throws TemplateModelException {
                TemplateModel model = wrapper.wrap(obj);
                if ( model instanceof SimpleHash ) {
                    SimpleHash hash = (SimpleHash) model;
                    if ( hash.get( "page" ) == null ) {
                        PageInfo pageInfo = (PageInfo) request.getAttributes().get( PageInfo.KEY );
                        if ( pageInfo != null ) {
View Full Code Here

        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(template.getObjectWrapper()).andReturn(objectWrapper);
        expect(objectWrapper.wrap("value")).andReturn(valueModel);

        replay(template, model, valueModel, configuration, objectWrapper);
        Environment env = new Environment(template, model, writer);
        EnvironmentScopeExtractor extractor = new EnvironmentScopeExtractor(env);
        extractor.setValue("key", "value");
View Full Code Here

        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(template.getObjectWrapper()).andReturn(objectWrapper);
        expect(objectWrapper.wrap("value")).andThrow(new TemplateModelException());

        replay(template, model, valueModel, configuration, objectWrapper);
        try {
            Environment env = new Environment(template, model, writer);
            EnvironmentScopeExtractor extractor = new EnvironmentScopeExtractor(env);
View Full Code Here

        Environment env = Environment.getCurrentEnvironment();
        TemplateModel nullModel = null;
        if(env != null) {
            ObjectWrapper wrapper = env.getObjectWrapper();
            if(wrapper != null) {
                nullModel = wrapper.wrap(null);
            }
        }
        return unwrap(model, nullModel, permissive);
    }
View Full Code Here

        {
            List list = new ArrayList();
            list.add("a");
            list.add("b");
           
            listList.add(ow.wrap(list));
        }
        {
            List list = new ArrayList();
            list.add("c");
           
View Full Code Here

        }
        {
            List list = new ArrayList();
            list.add("c");
           
            listList.add(ow.wrap(list));
        }
        return listList;
    }
   
    public List<int[]> getJavaListOfIntArrays() {
View Full Code Here

    public void testSetAttributePage() throws TemplateModelException {
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        GenericServlet servlet = createMock(GenericServlet.class);
        TemplateModel wrappedObj = createMock(TemplateModel.class);
        Integer myObj = new Integer(DUMMY_VALUE);
        expect(objectWrapper.wrap(myObj)).andReturn(wrappedObj);
        replay(servlet, objectWrapper);

        expect(template.getObjectWrapper()).andReturn(objectWrapper);

        replay(template, model, wrappedObj);
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.