You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by aa...@apache.org on 2013/11/02 23:48:18 UTC
svn commit: r1538298 - in /click/branches/click-3.0.0/click/framework:
src/org/apache/click/control/TextField.java
test/org/apache/click/control/TextFieldTest.java
Author: aadrian
Date: Sat Nov 2 22:48:17 2013
New Revision: 1538298
URL: http://svn.apache.org/r1538298
Log:
Fix default TextField Handling: issue #CLK-601
Modified:
click/branches/click-3.0.0/click/framework/src/org/apache/click/control/TextField.java
click/branches/click-3.0.0/click/framework/test/org/apache/click/control/TextFieldTest.java
Modified: click/branches/click-3.0.0/click/framework/src/org/apache/click/control/TextField.java
URL: http://svn.apache.org/viewvc/click/branches/click-3.0.0/click/framework/src/org/apache/click/control/TextField.java?rev=1538298&r1=1538297&r2=1538298&view=diff
==============================================================================
--- click/branches/click-3.0.0/click/framework/src/org/apache/click/control/TextField.java (original)
+++ click/branches/click-3.0.0/click/framework/src/org/apache/click/control/TextField.java Sat Nov 2 22:48:17 2013
@@ -106,8 +106,9 @@ public class TextField extends Field {
/** The field HTML5 placeholder attribute. */
protected String placeholder;
- /** The text field size attribute. The default size is 20. */
- protected int size = 20;
+ /** The text field size attribute. If the size is > 0, this is rendered as the
+ * HTML attribute 'size' . */
+ protected int size = 0;
// ----------------------------------------------------------- Constructors
@@ -366,7 +367,9 @@ public class TextField extends Field {
buffer.appendAttribute("name", getName());
buffer.appendAttribute("id", getId());
buffer.appendAttributeEscaped("value", getValue());
- buffer.appendAttribute("size", getSize());
+ if (getSize() > 0) {
+ buffer.appendAttribute("size", getSize());
+ }
buffer.appendAttribute("title", getTitle());
if (getTabIndex() > 0) {
buffer.appendAttribute("tabindex", getTabIndex());
Modified: click/branches/click-3.0.0/click/framework/test/org/apache/click/control/TextFieldTest.java
URL: http://svn.apache.org/viewvc/click/branches/click-3.0.0/click/framework/test/org/apache/click/control/TextFieldTest.java?rev=1538298&r1=1538297&r2=1538298&view=diff
==============================================================================
--- click/branches/click-3.0.0/click/framework/test/org/apache/click/control/TextFieldTest.java (original)
+++ click/branches/click-3.0.0/click/framework/test/org/apache/click/control/TextFieldTest.java Sat Nov 2 22:48:17 2013
@@ -28,6 +28,24 @@ import org.apache.click.servlet.MockRequ
public class TextFieldTest extends TestCase {
/**
+ * Tests TextField size handling.
+ *
+ * CLK-601
+ */
+ public void testSize(){
+ MockContext context = MockContext.initContext();
+ TextField textField = new TextField("text");
+ assertEquals(textField.getSize(),0); // default value is 0, i.e. is used from the browser.
+ assertTrue(!textField.toString().contains("size")); // the size parameter should not be rendered
+ System.out.println("textField.toString() = " + textField.toString());
+
+ TextField textField2 = new TextField("text2");
+ textField2.setSize(40); // if a size is set, than it should also be rendered.
+ assertTrue(textField2.toString().contains("size=\"40\""));
+ System.out.println("textField2.toString() = " + textField2.toString());
+ }
+
+ /**
* Test TextField onProcess behavior.
*/
public void testOnProcess() {