gigaZhang / struts2-jquery

Automatically exported from code.google.com/p/struts2-jquery
0 stars 0 forks source link

Layput busted for template css_xhtml #1092

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
(This is for feature requests and bugs in Struts2 jQuery Plugin - for
getting help, please use the User Group.
http://groups.google.com/group/struts2-jquery )

What steps will reproduce the problem?
1.Create a s:form with theme css_xhtml
2.Add sj:textfield inside the s:form
3.Add sj:datepicker inside the s:form

What is the expected output? What do you see instead?
The expected output is a label,textfield in divs for the text field and similar 
for the datepicker.  The divs should also be contained inside the form tag as 
well.
Instead I see some of the fields appearing outside the form

Which struts2 version?
2.3.16.1

Which struts2-jquery plugin version?
3.7.0

Please provide any additional information below.
Works as described in struts 2.3.15.1 and struts-jquery 3.6.1

Original issue reported on code.google.com by jeff.kre...@farecompare.com on 2 Apr 2014 at 8:35

GoogleCodeExporter commented 9 years ago
I have just upgraded my application to struts2 version 2.3.16.1 and 
struts2-jquery 3.7.0 and I am experiencing the same issue as all of my css 
layouts have been broken.
Not all the sj elements seem to cause an issue, e.g. sj:submit is fine, however 
the sj:autocompleter does break the layout.
I notice that many recent issues raised here have not been picked up an 
acknowledged by Johannes, so I wonder if there is still support for this plugin?

Original comment by stevendj...@gmail.com on 5 Apr 2014 at 9:45

GoogleCodeExporter commented 9 years ago
I have debugged this defect and found the cause, however, I have yet to find a 
reasonable solution. I have asked a question on the struts2 mailing list, the 
following is a copy what I sent:

Hi,
I am developing an application which has been predominantly written with 
Struts2 version 2.3.15.3 and the struts2-jquery-plugin version 3.6.1.
I have recently upgraded to Struts2 version 2.3.16.1 and struts2-jquery-plugin 
version 3.7.0.
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:

 <#if parameters.parentTheme == 'css_xhtml'>
  <#include "/${parameters.templateDir}/css_xhtml/controlheader.ftl" />
 </#if>

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:

<#include 
"/${parameters.templateDir}/${parameters.expandTheme}/controlheader-core.ftl">

And this is where it starts to go wrong. The ${parameters.expandTheme} 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 theme.properties 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.

Original comment by stevendj...@gmail.com on 9 Apr 2014 at 12:28

GoogleCodeExporter commented 9 years ago
The helpful guys of the Apache Struts team have provided the following solution:
Under your webapp directory, create your own controlheader-core.ftl template 
file with the path <webapp>\template\jquery\controlheader-core.ftl and add the 
following content:

<#assign parentTheme = parameters.parentTheme!"simple"/>
<#if parentTheme == 'xhtml'>
    <#include "/${parameters.templateDir}/xhtml/controlheader-core.ftl" />
</#if>
<#if parentTheme == 'css_xhtml'>
    <#include "/${parameters.templateDir}/css_xhtml/controlheader-core.ftl" />
</#if>

This will solve the layout issues. For more details see:
https://issues.apache.org/jira/browse/WW-4319

Original comment by stevendj...@gmail.com on 22 Apr 2014 at 8:52

GoogleCodeExporter commented 9 years ago
Sorry for the delay but is this Issue still a problem?

Original comment by johgep on 28 Apr 2014 at 12:57