struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Lenart (JIRA)" <>
Subject [jira] [Commented] (WW-4319) struts2-jquery-plugin custom tag templates broken
Date Sun, 13 Apr 2014 19:48:15 GMT


Lukasz Lenart commented on WW-4319:

I think I know where the problem is, the jQuery plugin basically extends {{xhtml}} theme but
it also internally supports {{css_xhtml}} theme, see code snippet below:
<#if parameters.parentTheme?if_exists == 'xhtml' || parameters.parentTheme?if_exists ==
'css_xhtml' || parameters.parentTheme?if_exists == 'simple'>
	<#if parameters.parentTheme == 'xhtml'>
		<#include "/${parameters.templateDir}/xhtml/controlheader.ftl" />
	<#if parameters.parentTheme == 'css_xhtml'>
		<#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
	<#if parameters.inline?default(false)>
		<#include "/${parameters.templateDir}/simple/hidden.ftl" />

The problem here is that Struts will try to include {{controlheader-core.ftl}} base on parent
theme, so it will be {{<#include "/${parameters.templateDir}/xhtml/controlheader-core.ftl"
/>}}, but your app is using {{css_xhtml}} and that's the case. The only solution is to
write custom {{controlheader-core.ftl}} (and any other required templates) with the same logic
as above.

It should be possible to do it inside the app, just create {{/template/jquery/controlheader-core.ftl}}
with the below content:
<#if parameters.parentTheme?? == 'xhtml'>
	<#include "/${parameters.templateDir}/xhtml/controlheader-core.ftl" />
<#if parameters.parentTheme?? == 'css_xhtml'>
	<#include "/${parameters.templateDir}/css_xhtml/controlheader-core.ftl" />

> struts2-jquery-plugin custom tag templates broken
> -------------------------------------------------
>                 Key: WW-4319
>                 URL:
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions:
>         Environment: Struts, struts2-jquery-plugin 3.7.0, tomcat v7.0
>            Reporter: Steven James
>             Fix For: 2.3.18
>         Attachments: http-response.png,
> Hi,
> I am developing an application which has been predominantly written with Struts2 version and the struts2-jquery-plugin version 3.6.1.
> I have recently upgraded to Struts2 version and struts2-jquery-plugin version
> The application has used the css_xhtml theme throughout, defined in struts.xml.
> Since the upgrade, the HTML markup of the struts2-jquery-plugin ( sj: ) components has
been adversly affected.
> I have debugged the application and found that the issue is caused by the changes made
to themes under WW-4145.
> The situation appears to be this:
> The struts2-jquery-plugin has implemented custom tags for their components and these
classes will return the value of 'jquery' in response to the getTheme() method. They do appear
to correctly store a 'parentTheme' parameter with the correct value (in my case from the parent
form element) of 'css_xhtml'.
> The struts2-jquery-plugin custom templates are successfully found on the templates/jquery
path, but some of them contain 'include' statements, for example, the datepicker.ftl contains
the following snippet:
>  {code:xml}
> <#if parameters.parentTheme == 'css_xhtml'>
> <#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
> </#if>
> {code}
> So, at this point, all is well, the correct controlheader.ftl template for the css_xhtml
theme is found and included, however this template (now) contains the following include:
> {code:xml} 
> <#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader-core.ftl">
> {code}
> And this is where it starts to go wrong. The {noformat}${parameters.expandTheme}{noformat}
resolves to '~~~jquery' and, after reading the WW-4145 change info, I understand that this
will cause the ThemeManager to load the template from the parent theme as defined in the
file. This, in the case of the struts2-jquery-plugin, is defiend as 'xhtml' and NOT 'css_xhtml'
as discovered from the parent form component. Consequently, the wrong controlheader-core.ftl
template is included, and the resulting HTML includes incorrect <tr> and <td>
tags which ultimately break the page.
> Other than hacking the templates, I cannot see a satisfactory way of resolving this problem,
so any assistance would be gratefully received.
> Thanks
> Steve

This message was sent by Atlassian JIRA

View raw message