Skip to content

Commit

Permalink
WW-4355 Replace depreacted HTML attributes with CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Jun 26, 2015
2 parents 46b0ef6 + bcf4d80 commit 4672c9e
Show file tree
Hide file tree
Showing 55 changed files with 97 additions and 138 deletions.
10 changes: 0 additions & 10 deletions core/src/main/java/org/apache/struts2/components/FormButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public abstract class FormButton extends ClosingUIBean {

protected String action;
protected String method;
protected String align;
protected String type;

public FormButton(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
Expand All @@ -52,9 +51,6 @@ public FormButton(ValueStack stack, HttpServletRequest request, HttpServletRespo
//public void evaluateParams() {
public void evaluateExtraParams() {
super.evaluateExtraParams();
if (align == null) {
align = "right";
}

String submitType = BUTTONTYPE_INPUT;
if (type != null && (BUTTONTYPE_BUTTON.equalsIgnoreCase(type) || (supportsImageType() && BUTTONTYPE_IMAGE.equalsIgnoreCase(type))))
Expand Down Expand Up @@ -88,8 +84,6 @@ public void evaluateExtraParams() {
addParameter("name", name);
}

addParameter("align", findString(align));

}

/**
Expand Down Expand Up @@ -158,10 +152,6 @@ public void setMethod(String method) {
this.method = method;
}

@StrutsTagAttribute(description="HTML align attribute.")
public void setAlign(String align) {
this.align = align;
}

@StrutsTagAttribute(description="The type of submit to use. Valid values are <i>input</i>, " +
"<i>button</i> and <i>image</i>.", defaultValue="input")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class ResetTag extends AbstractUITag {

protected String action;
protected String method;
protected String align;
protected String type;
protected String src;

Expand All @@ -51,7 +50,6 @@ protected void populateParams() {
Reset reset = ((Reset) component);
reset.setAction(action);
reset.setMethod(method);
reset.setAlign(align);
reset.setType(type);
reset.setSrc(src);
}
Expand All @@ -64,10 +62,6 @@ public void setMethod(String method) {
this.method = method;
}

public void setAlign(String align) {
this.align = align;
}

public void setType(String type) {
this.type = type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class SubmitTag extends AbstractClosingTag {

protected String action;
protected String method;
protected String align;
protected String type;
protected String src;

Expand All @@ -52,7 +51,6 @@ protected void populateParams() {
Submit submit = ((Submit) component);
submit.setAction(action);
submit.setMethod(method);
submit.setAlign(align);
submit.setType(type);
submit.setSrc(src);
}
Expand All @@ -65,10 +63,6 @@ public void setMethod(String method) {
this.method = method;
}

public void setAlign(String align) {
this.align = align;
}

public String getType() {
return type;
}
Expand Down
4 changes: 1 addition & 3 deletions core/src/main/resources/template/css_xhtml/reset.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
<#else>
<span <#rt/>
</#if>
<#if parameters.align??>
align="${parameters.align?html}"<#t/>
</#if>
class="formButton"<#t/>
<#if parameters.id??>
id="wwctrl_${parameters.id}"<#rt/>
</#if>
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/resources/template/css_xhtml/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@
.checkboxLabel {}
.checkboxErrorLabel {color:red; }
.required {color:red;}

.tdTransferSelect {text-align:center; vertical-align:middle;}
.tdLabelTop {text-align:left; vertical-align:top;}
.tdCheckboxLabel {text-align:right; vertical-align:top;}
.tdCheckboxInput {text-align:left; vertical-align:top;}
.tdCheckboxErrorMessage {text-align:left; vertical-align:top;}
.tdErrorMessage {text-align:center; vertical-align:top;}
.formButton {text-align:right;}
4 changes: 1 addition & 3 deletions core/src/main/resources/template/css_xhtml/submit.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
<#else>
<span <#rt/>
</#if>
<#if parameters.align??>
align="${parameters.align?html}"<#t/>
</#if>
class="formButton"<#t/>
<#if parameters.id??>
id="wwctrl_${parameters.id}"<#rt/>
</#if>
Expand Down
17 changes: 12 additions & 5 deletions core/src/main/resources/template/simple/debug.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
}
-->
</script>

<style type="text/css">
<!--
table.debugTable {border-collapse:collapse; border-spacing:0; background-color:#DDDDDD;}
table.debugTable th, table.debugTable td {padding:2px;}
-->
</style>
<p />
<a href="#" onclick="toggleDebug('<#if parameters.id?if_exists != "">${parameters.id?html}<#else>debug</#if>');return false;">[Debug]</a>
Expand All @@ -43,7 +50,7 @@
<p />
<h3>Value Stack Contents</h3>
<table border="0" cellpadding="2" cellspacing="0" bgcolor="#DDDDDD">
<table class="debugTable">
<tr><th>Object</th><th>Property Name</th><th>Property Value</th></tr>
<#assign index=1>
Expand All @@ -54,8 +61,8 @@
<#assign renderRow=false>
<#list stackObject.value.keySet() as propertyName>
<#if renderRow==true></tr><tr><#else> <#assign renderRow=false> </#if>
<td bgcolor="<#if (index % 2) == 0>#BBBBBB<#else>#CCCCCC</#if>">${propertyName}</td>
<td bgcolor="<#if (index % 2) == 0>#BBBBBB<#else>#CCCCCC</#if>"><#if stackObject.value.get(propertyName)??>${stackObject.value.get(propertyName).toString()?html}<#else>null</#if></td>
<td style="background-color:<#if (index % 2) == 0>#BBBBBB<#else>#CCCCCC</#if>;">${propertyName}</td>
<td style="background-color:<#if (index % 2) == 0>#BBBBBB<#else>#CCCCCC</#if>;"><#if stackObject.value.get(propertyName)??>${stackObject.value.get(propertyName).toString()?html}<#else>null</#if></td>
</tr>
<#assign index= index + 1>
</#list>
Expand All @@ -65,14 +72,14 @@
<h3>Stack Context</h3>
<i>These items are available using the #key notation</i>
<table border="0" cellpadding="2" cellspacing="0" bgcolor="#DDDDDD">
<table class="debugTable">
<tr>
<th>Key</th><th>Value</th>
</tr>
<#assign index=1>
<#list stack.context.keySet() as contextKey>
<tr bgcolor="<#if (index % 2) == 0>#BBBBBB<#else>#CCCCCC</#if>">
<tr style="background-color:<#if (index % 2) == 0>#BBBBBB<#else>#CCCCCC</#if>;">
<td>${contextKey}</td>
<td><#if stack.context.get(contextKey)??>${struts.toStringSafe(stack.context.get(contextKey))?html}<#else>null</#if></td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script type="text/javascript" src="<@s.url value="/struts/inputtransferselect.js" encode='false' includeParams='none'/>"></script>
<#assign temporaryVariable = stack.setValue("#inputtransferselect_js_included", "true") /><#t/>
</#if><#t/>
<table border="0">
<table>
<tr>
<td>
<#if parameters.leftTitle??><#t/>
Expand Down Expand Up @@ -61,7 +61,7 @@


</td>
<td valign="middle" align="center">
<td class="tdTransferSelect">
<#assign addLabel=(parameters.addLabel!"->")?html /><#t/>
<input type="button"
<#if parameters.buttonCssClass?has_content><#t/>
Expand Down Expand Up @@ -121,4 +121,4 @@
</#if>
</td>
</tr>
</table>
</table>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script type="text/javascript" src="<@s.url value="/struts/optiontransferselect.js" encode='false' includeParams='none'/>"></script>
<#assign temporaryVariable = stack.setValue("#optiontransferselect_js_included", "true") /><#t/>
</#if><#t/>
<table border="0">
<table>
<tr>
<td>
<#if parameters.leftTitle??><#t/>
Expand All @@ -47,7 +47,7 @@
</#if>

</td>
<td valign="middle" align="center">
<td class="tdTransferSelect">
<#if parameters.allowAddToLeft?default(true)><#t/>
<#assign addToLeftLabel = parameters.addToLeftLabel?default("<-")?html/><#t/>
<#if parameters.doubleHeaderKey??><#t/>
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/resources/template/xhtml/checkbox.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
errorFor="${parameters.id}"<#rt/>
</#if>
>
<td align="left" valign="top" colspan="2"><#rt/>
<td class="tdCheckboxErrorMessage" colspan="2"><#rt/>
<span class="errorMessage">${error?html}</span><#t/>
</td><#lt/>
</tr>
Expand Down Expand Up @@ -72,7 +72,7 @@ ${parameters.label?html}<#t/>
<#include "/${parameters.templateDir}/simple/checkbox.ftl" />
<#else>
<tr>
<td valign="top" align="right">
<td class="tdCheckboxLabel">
<#if labelpos?default("") == 'left'>
<#if parameters.label??> <label<#t/>
<#if parameters.id??>
Expand Down Expand Up @@ -107,7 +107,7 @@ ${parameters.label?html}<#t/>
</#if>
</#if>
</td>
<td valign="top" align="left">
<td class="tdCheckboxInput">

<#if labelpos?default("") != 'top'>
<#include "/${parameters.templateDir}/simple/checkbox.ftl" />
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/template/xhtml/controlfooter.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ${parameters.after?if_exists}<#t/>
<#if hasFieldErrors>
<#list fieldErrors[parameters.name] as error>
<tr errorFor="${parameters.id}">
<td align="center" valign="top" colspan="2"><#rt/>
<td class="tdErrorMessage" colspan="2"><#rt/>
<span class="errorMessage">${error?html}</span><#t/>
</td><#lt/>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/template/xhtml/controlheader-core.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<#if hasFieldErrors>
<#list fieldErrors[parameters.name] as error>
<tr errorFor="${parameters.id}">
<td align="center" valign="top" colspan="2"><#rt/>
<td class="tdErrorMessage" colspan="2"><#rt/>
<span class="errorMessage">${error?html}</span><#t/>
</td><#lt/>
</tr>
Expand All @@ -47,7 +47,7 @@
-->
<tr>
<#if labelpos?default("") == 'top'>
<td align="left" valign="top" colspan="2"><#rt/>
<td class="tdLabelTop" colspan="2"><#rt/>
<#else>
<td class="tdLabel"><#rt/>
</#if>
Expand Down
3 changes: 0 additions & 3 deletions core/src/main/resources/template/xhtml/controlheader.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,4 @@
-->
<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader-core.ftl" />
<td
<#if parameters.align??>
align="${parameters.align?html}"<#t/>
</#if>
><#t/>
6 changes: 1 addition & 5 deletions core/src/main/resources/template/xhtml/reset.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
*/
-->
<tr>
<td colspan="2"><div <#rt/>
<#if parameters.align??>
align="${parameters.align?html}"<#t/>
</#if>
><#t/>
<td colspan="2"><div class="formButton"><#t/>
<#include "/${parameters.templateDir}/simple/reset.ftl" />
</div><#t/>
<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" />
10 changes: 9 additions & 1 deletion core/src/main/resources/template/xhtml/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@
.checkboxLabel {}
.checkboxErrorLabel {color:red; }
.required {color:red;}
.tdLabel {text-align:right; vertical-align:top; }
.tdLabel {text-align:right; vertical-align:top; }

.tdTransferSelect {text-align:center; vertical-align:middle;}
.tdLabelTop {text-align:left; vertical-align:top;}
.tdCheckboxLabel {text-align:right; vertical-align:top;}
.tdCheckboxInput {text-align:left; vertical-align:top;}
.tdCheckboxErrorMessage {text-align:left; vertical-align:top;}
.tdErrorMessage {text-align:center; vertical-align:top;}
.formButton {text-align:right;}
6 changes: 1 addition & 5 deletions core/src/main/resources/template/xhtml/submit.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,5 @@
*/
-->
<tr>
<td colspan="2"><div <#rt/>
<#if parameters.align??>
align="${parameters.align?html}"<#t/>
</#if>
><#t/>
<td colspan="2"><div class="formButton"><#t/>
<#include "/${parameters.templateDir}/simple/submit.ftl" />
3 changes: 1 addition & 2 deletions core/src/main/resources/template/xhtml/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ function addErrorXHTML(e, errorText) {
var tr = document.createElement("tr");
var td = document.createElement("td");
var span = document.createElement("span");
td.align = "center";
td.valign = "top";
td.className = "tdErrorMessage";
td.colSpan = 2;
span.setAttribute("class", "errorMessage");
span.setAttribute("className", "errorMessage"); //ie hack cause ie does not support setAttribute
Expand Down
8 changes: 0 additions & 8 deletions core/src/site/resources/tags/reset.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ <h2>Attributes</h2>
<td align="left" valign="top">String</td>
<td align="left" valign="top">Set action attribute.</td>
</tr>
<tr>
<td align="left" valign="top">align</td>
<td align="left" valign="top">false</td>
<td align="left" valign="top"></td>
<td align="left" valign="top">false</td>
<td align="left" valign="top">String</td>
<td align="left" valign="top">HTML align attribute.</td>
</tr>
<tr>
<td align="left" valign="top">class</td>
<td align="left" valign="top">false</td>
Expand Down
8 changes: 0 additions & 8 deletions core/src/site/resources/tags/submit.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ <h2>Attributes</h2>
<td align="left" valign="top">String</td>
<td align="left" valign="top">Set action attribute.</td>
</tr>
<tr>
<td align="left" valign="top">align</td>
<td align="left" valign="top">false</td>
<td align="left" valign="top"></td>
<td align="left" valign="top">false</td>
<td align="left" valign="top">String</td>
<td align="left" valign="top">HTML align attribute.</td>
</tr>
<tr>
<td align="left" valign="top">class</td>
<td align="left" valign="top">false</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public void testSimple() throws Exception {
ResetTag tag = new ResetTag();
tag.setPageContext(pageContext);
tag.setLabel("mylabel");
tag.setAlign("left");
tag.setName("myname");
tag.setValue("%{foo}");

Expand Down Expand Up @@ -91,7 +90,6 @@ public void testButtonWithLabel() throws Exception {
tag.setPageContext(pageContext);
tag.setLabel("mylabel");
tag.setType("button");
tag.setAlign("left");
tag.setName("myname");
tag.setValue("%{foo}");

Expand Down Expand Up @@ -166,7 +164,6 @@ public void testSimpleThemeImageUsingActionAndMethod() throws Exception {
tag.setLabel("mylabel");
tag.setAction("manager");
tag.setMethod("update");
tag.setAlign("left");

tag.doStartTag();
tag.doEndTag();
Expand All @@ -186,7 +183,6 @@ public void testSimpleThemeImageUsingActionOnly() throws Exception {
tag.setLabel("mylabel");
tag.setAction("manager");
tag.setMethod(null); // no method
tag.setAlign("left");

tag.doStartTag();
tag.doEndTag();
Expand All @@ -206,7 +202,6 @@ public void testSimpleThemeImageUsingMethodOnly() throws Exception {
tag.setLabel("mylabel");
tag.setAction(null); // no action
tag.setMethod("update");
tag.setAlign("left");

tag.doStartTag();
tag.doEndTag();
Expand Down
Loading

0 comments on commit 4672c9e

Please sign in to comment.