[ 
https://issues.apache.org/jira/browse/WW-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13249306#comment-13249306
 ] 

Vijayakannan commented on WW-3764:
----------------------------------

Hope you have understand the above mentioned issue.

Issue # 2 in the ticket

struts.xml
<constant name="struts.ui.templateDir" value="struts-template"></constant>

web.xml

<context-param>
  <param-name>TemplatePath</param-name>
  <param-value>file://D://templates</param-value>
</context-param>

The purpose of TemplatePath is more powerful when compare to others, since it 
helps us to load the template from file system.

when i try to load the template from file system, i am getting FileNotException.

java.io.FileNotFoundException: Template /struts-template/xhtml/a.ftl not found.
        at freemarker.template.Configuration.getTemplate(Configuration.java:489)
        at freemarker.template.Configuration.getTemplate(Configuration.java:452)
        at 
org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:96)


Root Cause:

BaseTemplateEngine.java loadProperties(String propName) method doesn't include 
TemplatePath which is defined in web.xml.

private InputStream readProperty(String propName) {
InputStream is = tryReadingPropertyFileFromFileSystem(propName);
if (is == null) { is = readPropertyFromClasspath(propName); }
return is;
}

In my case , propName is "struts-template/xhtml/theme.properties"

Please note i have raise two related problem in this ticket.

Thanks in advance

                
> Reading(theme.properties)PropertyFileFromFileSystem doesn't include 
> templatePath value from web.xml
> ---------------------------------------------------------------------------------------------------
>
>                 Key: WW-3764
>                 URL: https://issues.apache.org/jira/browse/WW-3764
>             Project: Struts 2
>          Issue Type: Temp
>    Affects Versions: 2.3.1
>         Environment: Tomcat v7.0
>            Reporter: Vijayakannan
>              Labels: theme.properties-loading-from-filesystem
>             Fix For: 2.3.x
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> There is an option in Struts2 to load the freemarker template from path by 
> setting in web.xml (templatePath).Templates are loaded from the file system 
> if we configure the file path.
> Also there is an option to extend the themes by setting the value for 
> "parent" key in the themes.properties within the template folder
> readProperty() method helps us to read the themes.properties file from the 
> file system and also from the classpath
> Aruguments :- 
> Combination of template directory ,template and file name "theme.properties"  
> are passed as propName
> This method doesn't help us to load the theme.properties from the specified 
> templatePath 
> private InputStream readProperty(String propName) {
>         InputStream is = tryReadingPropertyFileFromFileSystem(propName);
>         if (is == null) {
>             is = readPropertyFromClasspath(propName);
>         }
>         return is;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to