Commits

Anonymous committed 8538565

adder freemarker example page

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@108573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (4)

                 <classpath id='../../build/example'/>
                 <classpath id='../etc/example'/>
                 <classpath id='../../lib/core' library-dir="true"/>
+                <classpath id='../../lib/optional' library-dir="true"/>
                 <classpath id='../../lib/example' library-dir="true"/>
 
             </web-app>

src/etc/example/xwork.xml

 <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">
 
 <xwork>
+
     <include file="webwork-default.xml"/>
     <include file="config-browser.xml"/>
 
             </result>
         </action>
 
+        <action name="FreemarkerTest" class="com.opensymphony.webwork.example.ui.SimpleCountry">
+            <result name="success" type="dispatcher">
+                <param name="location">/country.ftl</param>
+            </result>
+        </action>
+
         <action name="IteratorTest" class="com.opensymphony.webwork.example.IteratorExample">
 
             <result name="success" type="dispatcher">

src/webapp/WEB-INF/web.xml

         <servlet-class>com.opensymphony.webwork.views.jasperreports.JasperReportViewServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
     </servlet>
+    
+    <servlet>
+        <servlet-name>freemarker</servlet-name>
+        <servlet-class>com.opensymphony.webwork.views.freemarker.FreemarkerServlet</servlet-class>
+
+      <!-- FreemarkerServlet settings: -->
+      <init-param>
+        <param-name>TemplatePath</param-name>
+        <param-value>/</param-value>
+      </init-param>
+      <init-param>
+        <param-name>NoCache</param-name>
+        <param-value>true</param-value>
+      </init-param>
+      <init-param>
+        <param-name>ContentType</param-name>
+        <param-value>text/html</param-value>
+      </init-param>
+        
+      <!-- FreeMarker settings: -->
+      <init-param>
+        <param-name>template_update_delay</param-name>
+        <param-value>0</param-value> <!-- 0 is for development only! Use higher value otherwise. -->
+      </init-param>
+      <init-param>
+        <param-name>default_encoding</param-name>
+        <param-value>ISO-8859-1</param-value>
+      </init-param>
+      <init-param>
+        <param-name>number_format</param-name>
+        <param-value>0.##########</param-value>
+      </init-param>
+    
+      <load-on-startup>1</load-on-startup>
+    </servlet>
+
+   <servlet-mapping>
+        <servlet-name>freemarker</servlet-name>
+        <url-pattern>*.ftl</url-pattern>
+    </servlet-mapping>
 
    <servlet-mapping>
         <servlet-name>jasperreports</servlet-name>

src/webapp/country.ftl

+<#assign benchmark=JspTaglibs["/WEB-INF/taglibs-benchmark.tld"] />
+<#assign webwork=JspTaglibs["/WEB-INF/webwork.tld"] />
+
+<#assign count = 100/>
+
+<h2>generate output below ${count} times</h2>
+<@benchmark.duration >
+	<@repeat macro=output count=count/>
+</@benchmark.duration>
+
+<hr>
+<@output/>
+
+<#macro output count=1>
+	<ul>
+		<#list countries as country>
+			<li>${country[0]}</li>
+		</#list>
+	</ul>
+</#macro>
+
+<#macro repeat macro count>
+	<#list 1..count as c>
+		<@macro/>
+	</#list>
+</#macro>