struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Payne (JIRA)" <j...@apache.org>
Subject [jira] Updated: (WW-3079) Allow for wiring global macro Freemarker library's within FreemarkerManager
Date Thu, 02 Jul 2009 14:03:59 GMT

     [ https://issues.apache.org/struts/browse/WW-3079?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Matthew Payne updated WW-3079:
------------------------------

    Attachment: PMLFreeMarkerConfigurationFactoryBean.java


relavant code. 
   @Override
    public void afterPropertiesSet() throws IOException, TemplateException {
        this.configuration = createConfiguration();
        configuration.setTemplateUpdateDelay(5);
        configuration.setURLEscapingCharset(urlEscapingCharset);
        if (useComputerNumberFormat) {
            configuration.setNumberFormat("#0.#");
        }
        configuration.setEncoding(Locale.US, urlEscapingCharset);
        importMacroLibraries(configuration);
        configuration.setTemplateExceptionHandler(exceptionHandler);
    }


    protected void importAutoIncludes(Configuration config) {
        if (autoIncludedTemplates != null) {
            for (String templateName : autoIncludedTemplates) {
                config.addAutoInclude(templateName);
            }
        }
    }

    protected void importMacroLibraries(Configuration config) {
        if (macroLibraries != null) {
            Enumeration<?> names = macroLibraries.propertyNames();
            while (names.hasMoreElements()) {
                String namespace = (String) names.nextElement();
                String lib = macroLibraries.getProperty(namespace);
                config.addAutoImport(namespace, lib);
            }
        }
    }

> Allow for wiring global macro Freemarker library's within FreemarkerManager
> ---------------------------------------------------------------------------
>
>                 Key: WW-3079
>                 URL: https://issues.apache.org/struts/browse/WW-3079
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Integration
>    Affects Versions: 2.1.8
>            Reporter: Matthew Payne
>             Fix For: 2.1.8
>
>         Attachments: PMLFreeMarkerConfigurationFactoryBean.java
>
>
> Something similar can can be setup via for velocity Macro's .  We should be able to set
certain macro libs as global without needing to import them directly in our freemarker templates.

> Such a setting is currently not available in the current FreemarkerManager
> example of setting this up in another project(not struts based). 
> reference --> http://svn.riotfamily.org/svn/riotfamily/trunk/website/META-INF/riot/website-servlet.xml
> ---> notice macro lib property
> <bean id="freemarkerConfig" class="org.riotfamily.website.freemarker.WebsiteFreeMarkerConfigurer">
> 		<description>
> 			FreeMarker configuration.
> 		</description>
> 		<property name="defaultEncoding" value="UTF-8" />
> 		<property name="templateLoaderPaths">
> 		    <list>
> 		        <value>/WEB-INF/view</value>
> 		    </list>
> 		</property>
> 		<property name="freemarkerSettings" value="${website-servlet.freemarker.*}" />
> 		<property name="useTemplateCache" value="${website-servlet.useTemplateCache=true}"
/>
> 		<property name="macroLibraries">
> 			<props>
> 				<prop key="c">classpath:org/riotfamily/website/view/common.ftl</prop>
> 				<prop key="form">classpath:org/riotfamily/website/form/form.ftl</prop>
> 				<prop key="template">classpath:org/riotfamily/website/template/template.ftl</prop>
> 				<prop key="txt2img">classpath:org/riotfamily/website/txt2img/txt2img.ftl</prop>
> 			</props>
> 		</property>
> 		<property name="whitespaceStripping" value="true" />
> 	</bean>
> http://www.java2s.com/Open-Source/Java-Document/Content-Management-System/riotfamily/org/riotfamily/common/web/view/freemarker/RiotFreeMarkerConfigurer.java.htm
>   protected void importMacroLibraries(Configuration config) {
> 192:                if (macroLibraries != null) {
> 193:                    Enumeration names = macroLibraries.propertyNames();
> 194:                    while (names.hasMoreElements()) {
> 195:                        String namespace = (String) names.nextElement();
> 196:                        String lib = macroLibraries.getProperty(namespace);
> 197:                        log
> 198:                                .info(lib + " imported under namespace "
> 199:                                        + namespace);
> 200:                        config.addAutoImport(namespace, lib);
> 201:                    }
> 202:                }
> 203:            }
>      /**
> 074:             * Sets the macro libraries to be auto-imported, keyed by their namespace.
> 075:             */
> 076:            public void setMacroLibraries(Properties macroLibraries) {
> 077:                this .macroLibraries = macroLibraries;
> 078:            }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message