You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by jo...@apache.org on 2012/09/24 21:43:45 UTC
svn commit: r1389534 - in /struts/struts2/trunk/core/src:
main/java/org/apache/struts2/components/
main/java/org/apache/struts2/views/jsp/ui/ main/resources/template/simple/
site/resources/tags/ test/java/org/apache/struts2/views/jsp/ui/
test/resources...
Author: jogep
Date: Mon Sep 24 19:43:44 2012
New Revision: 1389534
URL: http://svn.apache.org/viewvc?rev=1389534&view=rev
Log:
WW-388: Update UI tags in FreeMarker to allow new HTML input types
Added:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-7.txt
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TextField.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/TextFieldTag.java
struts/struts2/trunk/core/src/main/resources/template/simple/text.ftl
struts/struts2/trunk/core/src/site/resources/tags/combobox.html
struts/struts2/trunk/core/src/site/resources/tags/password.html
struts/struts2/trunk/core/src/site/resources/tags/textfield.html
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TextField.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TextField.java?rev=1389534&r1=1389533&r2=1389534&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TextField.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TextField.java Mon Sep 24 19:43:44 2012
@@ -21,13 +21,12 @@
package org.apache.struts2.components;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
-import com.opensymphony.xwork2.util.ValueStack;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
/**
* <!-- START SNIPPET: javadoc -->
@@ -67,6 +66,7 @@ public class TextField extends UIBean {
protected String maxlength;
protected String readonly;
protected String size;
+ protected String type;
public TextField(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
super(stack, request, response);
@@ -90,6 +90,11 @@ public class TextField extends UIBean {
if (readonly != null) {
addParameter("readonly", findValue(readonly, Boolean.class));
}
+
+ if (type != null) {
+ addParameter("type", findString(type));
+ }
+
}
@StrutsTagAttribute(description="HTML maxlength attribute", type="Integer")
@@ -111,4 +116,9 @@ public class TextField extends UIBean {
public void setSize(String size) {
this.size = size;
}
+
+ @StrutsTagAttribute(description="Specifies the html5 type element to display. e.g. text, email, url", defaultValue="text")
+ public void setType(String type) {
+ this.type = type;
+ }
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/TextFieldTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/TextFieldTag.java?rev=1389534&r1=1389533&r2=1389534&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/TextFieldTag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/TextFieldTag.java Mon Sep 24 19:43:44 2012
@@ -21,13 +21,12 @@
package org.apache.struts2.views.jsp.ui;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.components.Component;
import org.apache.struts2.components.TextField;
-import com.opensymphony.xwork2.util.ValueStack;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
/**
* @see TextField
@@ -39,6 +38,7 @@ public class TextFieldTag extends Abstra
protected String maxlength;
protected String readonly;
protected String size;
+ protected String type;
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return new TextField(stack, req, res);
@@ -51,6 +51,7 @@ public class TextFieldTag extends Abstra
textField.setMaxlength(maxlength);
textField.setReadonly(readonly);
textField.setSize(size);
+ textField.setType(type);
}
/**
@@ -71,4 +72,8 @@ public class TextFieldTag extends Abstra
public void setSize(String size) {
this.size = size;
}
+
+ public void setType(String type) {
+ this.type = type;
+ }
}
Modified: struts/struts2/trunk/core/src/main/resources/template/simple/text.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/simple/text.ftl?rev=1389534&r1=1389533&r2=1389534&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/template/simple/text.ftl (original)
+++ struts/struts2/trunk/core/src/main/resources/template/simple/text.ftl Mon Sep 24 19:43:44 2012
@@ -20,7 +20,8 @@
* under the License.
*/
-->
-<input type="text"<#rt/>
+<input<#rt/>
+ type="${parameters.type?default("text")?html}"<#rt/>
name="${parameters.name?default("")?html}"<#rt/>
<#if parameters.get("size")??>
size="${parameters.get("size")?html}"<#rt/>
Modified: struts/struts2/trunk/core/src/site/resources/tags/combobox.html
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/site/resources/tags/combobox.html?rev=1389534&r1=1389533&r2=1389534&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/site/resources/tags/combobox.html (original)
+++ struts/struts2/trunk/core/src/site/resources/tags/combobox.html Mon Sep 24 19:43:44 2012
@@ -426,6 +426,14 @@ Please do not edit it directly.
<td align="left" valign="top">Icon path used for image that will have the tooltip</td>
</tr>
<tr>
+ <td align="left" valign="top">type</td>
+ <td align="left" valign="top">false</td>
+ <td align="left" valign="top">text</td>
+ <td align="left" valign="top">false</td>
+ <td align="left" valign="top">String</td>
+ <td align="left" valign="top">Specifies the html5 type element to display. e.g. text, email, url</td>
+ </tr>
+ <tr>
<td align="left" valign="top">value</td>
<td align="left" valign="top">false</td>
<td align="left" valign="top"></td>
Modified: struts/struts2/trunk/core/src/site/resources/tags/password.html
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/site/resources/tags/password.html?rev=1389534&r1=1389533&r2=1389534&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/site/resources/tags/password.html (original)
+++ struts/struts2/trunk/core/src/site/resources/tags/password.html Mon Sep 24 19:43:44 2012
@@ -386,6 +386,14 @@ Please do not edit it directly.
<td align="left" valign="top">Icon path used for image that will have the tooltip</td>
</tr>
<tr>
+ <td align="left" valign="top">type</td>
+ <td align="left" valign="top">false</td>
+ <td align="left" valign="top">text</td>
+ <td align="left" valign="top">false</td>
+ <td align="left" valign="top">String</td>
+ <td align="left" valign="top">Specifies the html5 type element to display. e.g. text, email, url</td>
+ </tr>
+ <tr>
<td align="left" valign="top">value</td>
<td align="left" valign="top">false</td>
<td align="left" valign="top"></td>
Modified: struts/struts2/trunk/core/src/site/resources/tags/textfield.html
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/site/resources/tags/textfield.html?rev=1389534&r1=1389533&r2=1389534&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/site/resources/tags/textfield.html (original)
+++ struts/struts2/trunk/core/src/site/resources/tags/textfield.html Mon Sep 24 19:43:44 2012
@@ -378,6 +378,14 @@ Please do not edit it directly.
<td align="left" valign="top">Icon path used for image that will have the tooltip</td>
</tr>
<tr>
+ <td align="left" valign="top">type</td>
+ <td align="left" valign="top">false</td>
+ <td align="left" valign="top">text</td>
+ <td align="left" valign="top">false</td>
+ <td align="left" valign="top">String</td>
+ <td align="left" valign="top">Specifies the html5 type element to display. e.g. text, email, url</td>
+ </tr>
+ <tr>
<td align="left" valign="top">value</td>
<td align="left" valign="top">false</td>
<td align="left" valign="top"></td>
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java?rev=1389534&r1=1389533&r2=1389534&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java Mon Sep 24 19:43:44 2012
@@ -21,14 +21,13 @@
package org.apache.struts2.views.jsp.ui;
-import java.util.HashMap;
-import java.util.Map;
-
+import freemarker.template.TransformControl;
import org.apache.struts2.TestAction;
import org.apache.struts2.views.freemarker.tags.TextFieldModel;
import org.apache.struts2.views.jsp.AbstractUITagTest;
-import freemarker.template.TransformControl;
+import java.util.HashMap;
+import java.util.Map;
/**
@@ -182,4 +181,21 @@ public class TextfieldTest extends Abstr
verify(TextFieldTag.class.getResource("Textfield-6.txt"));
}
+
+ public void testHtml5EmailTag() throws Exception {
+ TestAction testAction = (TestAction) action;
+ testAction.setFoo("bar");
+
+ TextFieldTag tag = new TextFieldTag();
+ tag.setPageContext(pageContext);
+ tag.setLabel("myemaillabel");
+ tag.setName("foo");
+ tag.setSize("50");
+ tag.setType("email");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(TextFieldTag.class.getResource("Textfield-7.txt"));
+ }
}
Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-7.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-7.txt?rev=1389534&view=auto
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-7.txt (added)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-7.txt Mon Sep 24 19:43:44 2012
@@ -0,0 +1,4 @@
+<tr>
+ <td class="tdLabel"><label for="foo" class="label">myemaillabel:</label></td>
+ <td><input type="email" name="foo" size="50" value="bar" id="foo"/></td>
+</tr>