Commits

Anonymous committed aa2e204

- ajax capabilities with css_xhtml theme

Issue number: WW-1317
Obtained from:
Submitted by:
Reviewed by:

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

  • Participants
  • Parent commits afc74e5

Comments (0)

Files changed (34)

File src/java/com/opensymphony/webwork/components/template/FreemarkerTemplateEngine.java

  * Freemarker based template engine.
  *
  * @author CameronBraid
+ * @author tm_jee
  */
 public class FreemarkerTemplateEngine extends BaseTemplateEngine {
     static Class bodyContent = null;
         SimpleHash model = freemarkerManager.buildTemplateModel(stack, action, servletContext, req, res, config.getObjectWrapper());
 
         model.put("tag", templateContext.getTag());
+        model.put("themeProperties", getThemeProps(templateContext.getTemplate()));
 
         // the BodyContent JSP writer doesn't like it when FM flushes automatically --
         // so let's just not do it (it will be flushed eventually anyway)

File src/java/com/opensymphony/webwork/views/freemarker/FreemarkerManager.java

 import freemarker.ext.beans.BeansWrapper;
 import freemarker.ext.jsp.TaglibFactory;
 import freemarker.ext.servlet.HttpRequestHashModel;
+import freemarker.ext.servlet.HttpRequestParametersHashModel;
 import freemarker.ext.servlet.HttpSessionHashModel;
 import freemarker.ext.servlet.ServletContextHashModel;
 import freemarker.template.*;
     private static final String ATTR_JSP_TAGLIBS_MODEL = ".freemarker.JspTaglibs";
     private static final String ATTR_SESSION_MODEL = ".freemarker.Session";
     private static final String ATTR_REQUEST_MODEL = ".freemarker.Request";
+    private static final String ATTR_REQUEST_PARAMETERS_MODEL = ".freemarker.RequestParameters";
 
     // coppied from freemarker servlet - so that there is no dependency on it
     public static final String KEY_APPLICATION = "Application";
     public static final String KEY_REQUEST_MODEL = "Request";
     public static final String KEY_SESSION_MODEL = "Session";
     public static final String KEY_JSP_TAGLIBS = "JspTaglibs";
+    public static final String KEY_REQUEST_PARAMETER_MODEL = "Parameters";
     private static FreemarkerManager instance = null;
 
 
         }
 
         model.put(KEY_REQUEST_MODEL, requestModel);
-
+        
+        
+        // Create hash model wrapper for request parameters
+        HttpRequestParametersHashModel reqParametersModel = (HttpRequestParametersHashModel) request.getAttribute(ATTR_REQUEST_PARAMETERS_MODEL);
+        if (reqParametersModel == null || requestModel.getRequest() != request) {
+        	reqParametersModel = new HttpRequestParametersHashModel(request);
+        	request.setAttribute(ATTR_REQUEST_PARAMETERS_MODEL, reqParametersModel);
+        }
+        model.put(KEY_REQUEST_PARAMETER_MODEL, reqParametersModel);
+        
         return model;
     }
 

File src/java/com/opensymphony/webwork/views/freemarker/FreemarkerResult.java

  */
 public class FreemarkerResult extends WebWorkResultSupport {
 
-    protected ActionInvocation invocation;
+	private static final long serialVersionUID = -3778230771704661631L;
+	
+	protected ActionInvocation invocation;
     protected Configuration configuration;
     protected ObjectWrapper wrapper;
 

File src/java/template/ajax/controlheader.ftl

-<#include "/${parameters.templateDir}/xhtml/controlheader-core.ftl" />
+<#--include "/${parameters.templateDir}/xhtml/controlheader-core.ftl" /-->
 <#if parameters.form?exists && parameters.form.validate?default(false) == true>
 	<#-- can't mutate the data model in freemarker -->
     <#if parameters.onblur?exists>
         ${tag.addParameter('onblur', "validate(this);")}
     </#if>
 </#if>
-    <td>
+<#include "/${parameters.templateDir}/${themeProperties.parent}/controlheader.ftl" />

File src/java/template/ajax/form.ftl

 <#if parameters.cssClass?exists>
  class="${parameters.cssClass?html}"<#rt/>
 </#if>
+<#if parameters.acceptcharset?exists>
+ accept-charset="${parameters.acceptcharset?html}"<#rt/>
+</#if>
 <#if parameters.cssStyle?exists>
  style="${parameters.cssStyle?html}"<#rt/>
 </#if>
  ${tag.addParameter("ajaxSubmit", "true")}
  onSubmit="return isAjaxFormSubmit(this);"
 >
+<#include "/${parameters.templateDir}/${themeProperties.parent}/control.ftl" />
+<#--
 <table class="${parameters.cssClass?default('wwFormTable')?html}"<#rt/>
 <#if parameters.cssStyle?exists> style="${parameters.cssStyle?html}"<#rt/>
 </#if>
 >
+-->

File src/java/template/ajax/head.ftl

-<#include "/${parameters.templateDir}/xhtml/head.ftl" />
-<script language="JavaScript" type="text/javascript">
-    // Dojo configuration
-    djConfig = {
-        baseRelativePath: "<@ww.url includeParams='none' value='/webwork/dojo/' encode='false'/>",
-        isDebug: ${parameters.debug},
-        bindEncoding: "${parameters.encoding}",
-        debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with the includes
-    };
-</script>
-<script language="JavaScript" type="text/javascript"
-        src="<@ww.url includeParams='none' value='/webwork/dojo/dojo.js' encode='false'/>"></script>
+<#--include "/${parameters.templateDir}/xhtml/head.ftl" /-->
+<#include "/${parameters.templateDir}/${themeProperties.parent}/head.ftl" />
 <script language="JavaScript" type="text/javascript"
         src="<@ww.url includeParams='none' value='/webwork/ajax/dojoRequire.js' encode='false'/>"></script>
 <script language="JavaScript" type="text/javascript"

File src/java/template/ajax/submit-ajax.ftl

+<#--
 <tr>
     <td colspan="2"><div <#rt/>
-<#if parameters.align?exists>
-    align="${parameters.align?html}"<#t/>
-</#if>
-><#t/>
+-->
+<#include "/${parameters.templateDir}/${themeProperties.parent}/controlheader.ftl" />
 <button type="submit" dojoType="BindButton"<#rt/>
 <#if parameters.form?exists && parameters.form.id?exists>
  formId="${parameters.form.id}"<#rt/>
 </#if>
 <#include "/${parameters.templateDir}/simple/scripting-events.ftl"/>
 ><#if parameters.nameValue?exists><@ww.property value="parameters.nameValue"/><#rt/></#if></button></div>
-<#include "/${parameters.templateDir}/xhtml/controlfooter.ftl" />
+<#--include "/${parameters.templateDir}/xhtml/controlfooter.ftl" /-->
+<#include "/${parameters.templateDir}/${themeProperties.parent}/controlfooter.ftl" />
+

File src/java/template/ajax/submit.ftl

 <#include "/${parameters.templateDir}/ajax/submit-ajax.ftl" />
 ${tag.addFormParameter("ajaxSubmit", "false")}
 <#else>
-<#include "/${parameters.templateDir}/xhtml/submit.ftl" />
+<#--include "/${parameters.templateDir}/xhtml/submit.ftl" /-->
+<#include "/${parameters.templateDir}/${themeProperties.parent}/submit.ftl" />
 </#if>

File src/java/template/ajax/textarea.ftl

 </#if>
 </textarea>
 
-<#include "/${parameters.templateDir}/xhtml/controlfooter.ftl" />
+<#--include "/${parameters.templateDir}/xhtml/controlfooter.ftl" /-->
+<#include "/${parameters.templateDir}/${themeProperties.parent}/controlfooter.ftl" />

File src/java/template/ajax/theme.properties

-parent = xhtml
+parent=xhtml

File src/java/template/css_xhtml/checkboxlist.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/checkboxlist.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" /><#nt/>

File src/java/template/css_xhtml/combobox.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/combobox.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" /><#nt/>

File src/java/template/css_xhtml/control-close.ftl

Empty file added.

File src/java/template/css_xhtml/control.ftl

Empty file added.

File src/java/template/css_xhtml/controlheader-core.ftl

+<#--
+	Only show message if errors are available.
+	This will be done if ActionSupport is used.
+-->
+<#assign hasFieldErrors = parameters.name?exists && fieldErrors?exists && fieldErrors[parameters.name]?exists/> 
+<div <#rt/><#if parameters.id?exists>id="wwgrp_${parameters.id}"<#rt/></#if> class="wwgrp">
+	
+<#if hasFieldErrors>
+<div <#rt/><#if parameters.id?exists>id="wwerr_${parameters.id}"<#rt/></#if> class="wwerr">
+<#list fieldErrors[parameters.name] as error>
+    <div<#rt/>
+    <#if parameters.id?exists>
+     errorFor="${parameters.id}"<#rt/>
+    </#if>
+    class="errorMessage">
+             ${error?html}
+    </div><#t/>
+</#list>
+</div><#t/>
+</#if>
+
+<#if parameters.label?exists>
+<#if parameters.labelposition?default("top") == 'top'>
+<div <#rt/>
+<#else>
+<span <#rt/>
+</#if>
+<#if parameters.id?exists>id="wwlbl_${parameters.id}"<#rt/></#if> class="wwlbl">
+    <label <#t/>
+<#if parameters.id?exists>
+        for="${parameters.id?html}" <#t/>
+</#if>
+<#if hasFieldErrors>
+        class="errorLabel"<#t/>
+<#else>
+        class="label"<#t/>
+</#if>
+    ><#t/>
+<#if parameters.required?default(false)>
+        <span class="required">*</span><#t/>
+</#if>
+        ${parameters.label?html}:
+<#include "/${parameters.templateDir}/xhtml/tooltip.ftl" />
+	</label><#t/>
+<#if parameters.labelposition?default("top") == 'top'>
+</div> <br/><#rt/>
+<#else>
+</span> <#rt/>
+</#if>
+</#if>

File src/java/template/css_xhtml/controlheader.ftl

-<#--
-	Only show message if errors are available.
-	This will be done if ActionSupport is used.
--->
-<#assign hasFieldErrors = parameters.name?exists && fieldErrors?exists && fieldErrors[parameters.name]?exists/> 
-<div <#rt/><#if parameters.id?exists>id="wwgrp_${parameters.id}"<#rt/></#if> class="wwgrp">
-	
-<#if hasFieldErrors>
-<div <#rt/><#if parameters.id?exists>id="wwerr_${parameters.id}"<#rt/></#if> class="wwerr">
-<#list fieldErrors[parameters.name] as error>
-    <div<#rt/>
-    <#if parameters.id?exists>
-     errorFor="${parameters.id}"<#rt/>
-    </#if>
-    class="errorMessage">
-             ${error?html}
-    </div><#t/>
-</#list>
-</div><#t/>
-</#if>
-
-<#if parameters.label?exists>
-<#if parameters.labelposition?default("top") == 'top'>
-<div <#rt/>
-<#else>
-<span <#rt/>
-</#if>
-<#if parameters.id?exists>id="wwlbl_${parameters.id}"<#rt/></#if> class="wwlbl">
-    <label <#t/>
-<#if parameters.id?exists>
-        for="${parameters.id?html}" <#t/>
-</#if>
-<#if hasFieldErrors>
-        class="errorLabel"<#t/>
-<#else>
-        class="label"<#t/>
-</#if>
-    ><#t/>
-<#if parameters.required?default(false)>
-        <span class="required">*</span><#t/>
-</#if>
-        ${parameters.label?html}:
-<#include "/${parameters.templateDir}/xhtml/tooltip.ftl" />
-	</label><#t/>
-<#if parameters.labelposition?default("top") == 'top'>
-</div> <br/><#rt/>
-<#else>
-</span> <#rt/>
-</#if>
-</#if>
-
+<#include "/${parameters.templateDir}/css_xhtml/controlheader-core.ftl">
 <#if parameters.labelposition?default("top") == 'top'>
 <div <#rt/>
 <#else>

File src/java/template/css_xhtml/datepicker.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/datepicker.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/css_xhtml/doubleselect.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/doubleselect.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" /><#nt/>

File src/java/template/css_xhtml/file.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/file.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/css_xhtml/form-close.ftl

+<#include "/${parameters.templateDir}/css_xhtml/control-close.ftl" />
 <#include "/${parameters.templateDir}/simple/form-close.ftl" />
 <#include "/${parameters.templateDir}/xhtml/form-close-validate.ftl" />

File src/java/template/css_xhtml/form.ftl

 <#include "/${parameters.templateDir}/css_xhtml/form-validate.ftl" />
 <#include "/${parameters.templateDir}/simple/form.ftl" />
+<#include "/${parameters.templateDir}/css_xhtml/control.ftl">

File src/java/template/css_xhtml/label.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <label<#rt/>
 <#if parameters.id?exists>
  id="${parameters.id?html}"<#rt/>

File src/java/template/css_xhtml/optiontransferselect.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/optiontransferselect.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/css_xhtml/password.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/password.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/css_xhtml/radiomap.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/radiomap.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />
 <#nt/>

File src/java/template/css_xhtml/richtexteditor.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/richtexteditor.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/css_xhtml/select.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/select.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/css_xhtml/text.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" / -->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/text.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/css_xhtml/textarea.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/textarea.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/css_xhtml/updownselect.ftl

-<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
+<#--include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" /-->
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
 <#include "/${parameters.templateDir}/simple/updownselect.ftl" />
 <#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

File src/java/template/xhtml/control-close.ftl

+</table>

File src/java/template/xhtml/control.ftl

+<table class="${parameters.cssClass?default('wwFormTable')?html}"<#rt/>
+<#if parameters.cssStyle?exists> style="${parameters.cssStyle?html}"<#rt/>
+</#if>
+>

File src/java/template/xhtml/form-close.ftl

-</table>
+<#include "/${parameters.templateDir}/xhtml/control-close.ftl" />
 <#include "/${parameters.templateDir}/simple/form-close.ftl" />
 <#include "/${parameters.templateDir}/xhtml/form-close-validate.ftl" />

File src/java/template/xhtml/form.ftl

 <#include "/${parameters.templateDir}/xhtml/form-validate.ftl" />
 <#include "/${parameters.templateDir}/simple/form.ftl" />
-<table class="${parameters.cssClass?default('wwFormTable')?html}"<#rt/>
-<#if parameters.cssStyle?exists> style="${parameters.cssStyle?html}"<#rt/>
-</#if>
->
+<#include "/${parameters.templateDir}/xhtml/control.ftl" />