Package freemarker.template

Examples of freemarker.template.TemplateHashModel


     */
    @Test
    public void testGetAsObject() throws TemplateModelException {
        TemplateNumberModel model = createMock(TemplateNumberModel.class);
        Template template = createMock(Template.class);
        TemplateHashModel rootDataModel = createMock(TemplateHashModel.class);
        Writer out = createMock(Writer.class);

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

View Full Code Here


     * @throws TemplateModelException If something goes wrong.
     */
    @Test
    public void testGetAsObjectDefault() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel rootDataModel = createMock(TemplateHashModel.class);
        Writer out = createMock(Writer.class);

        expect(template.getMacros()).andReturn(new HashMap<String, Macro>());

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

     */
    @Test(expected = FreemarkerAutotagException.class)
    public void testGetAsObjectException() throws TemplateModelException {
        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>());

View Full Code Here

    static private Logger logger = LoggerFactory.getLogger(FreemarkerUtil.class);
   
    static public <C> C getDataModel(String mapName, Class<C> c) {
        Environment env = Environment.getCurrentEnvironment();

        TemplateHashModel rootModel = env.getDataModel();
        Object tmpObj = rootModel;
        try {
            for (String key : mapName.split("\\.")) {
                if (tmpObj instanceof TemplateHashModel) {
                    tmpObj = ((TemplateHashModel) tmpObj).get(key);
View Full Code Here

    static private Logger logger = LoggerFactory.getLogger(FreemarkerUtil.class);
   
    static public <C> C getDataModel(String mapName, Class<C> c) {
        Environment env = Environment.getCurrentEnvironment();

        TemplateHashModel rootModel = env.getDataModel();
        Object tmpObj = rootModel;
        try {
            for (String key : mapName.split("\\.")) {
                if (tmpObj instanceof TemplateHashModel) {
                    tmpObj = ((TemplateHashModel) tmpObj).get(key);
View Full Code Here

                    Template template = new Template("FMImportFilter", templateReader, config);
                    NodeModel nodeModel = NodeModel.wrap(this.rootNodeForTemplate);

                    Map context = FastMap.newInstance();
                    BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
                    TemplateHashModel staticModels = wrapper.getStaticModels();
                    context.put("Static", staticModels);

                    context.put("doc", nodeModel);
                    template.process(context, outWriter);
                    String s = outWriter.toString();
View Full Code Here

        env.process();
    }
   
    public static void addAllOfbizTransforms(Map context) {
        BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
        TemplateHashModel staticModels = wrapper.getStaticModels();
        if (context == null) {
            context = FastMap.newInstance();
        }
        context.put("Static", staticModels);
        context.putAll(ftlTransforms);
View Full Code Here

    String evaluateMessage(WMSMapContent content) throws IOException, TemplateException {
        final Map env = content.getRequest().getEnv();
        Template t = new Template("name", new StringReader(messageTemplate),
                new Configuration());
        final BeansWrapper bw = new BeansWrapper();
        return FreeMarkerTemplateUtils.processTemplateIntoString(t, new TemplateHashModel() {
           
            @Override
            public boolean isEmpty() throws TemplateModelException {
                return env.isEmpty();
            }
View Full Code Here

    }
   
    public DebugModel[] get(String[] keys) throws TemplateModelException, RemoteException
    {
        DebugModel[] dm = new DebugModel[keys.length];
        TemplateHashModel h = (TemplateHashModel)model;
        for (int i = 0; i < keys.length; i++)
        {
            dm[i] = getDebugModel(h.get(keys[i]));
        }
        return dm;
    }
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateHashModel

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.