Author: karlvr Date: Wed Apr 25 17:10:28 2007 New Revision: 532548 URL: http://svn.apache.org/viewvc?view=rev&rev=532548 Log: Checkbox and Radio: added checked="true/false" attribute to force checked or not checked, changed checkedValue(s) to currentValue(s) to hopefully be clearer
Added: jakarta/taglibs/proper/input/trunk/xml/attributes/checked.xml - copied, changed from r531155, jakarta/taglibs/proper/input/trunk/xml/attributes/checkedvalue.xml Removed: jakarta/taglibs/proper/input/trunk/doc/web/index.html jakarta/taglibs/proper/input/trunk/xml/attributes/checkedvalue.xml Modified: jakarta/taglibs/proper/input/trunk/doc/web/input.html jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Checkbox.java jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Radio.java jakarta/taglibs/proper/input/trunk/xml/input.xml Modified: jakarta/taglibs/proper/input/trunk/doc/web/input.html URL: http://svn.apache.org/viewvc/jakarta/taglibs/proper/input/trunk/doc/web/input.html?view=diff&rev=532548&r1=532547&r2=532548 ============================================================================== --- jakarta/taglibs/proper/input/trunk/doc/web/input.html (original) +++ jakarta/taglibs/proper/input/trunk/doc/web/input.html Wed Apr 25 17:10:28 2007 @@ -175,3 +175,6 @@ Shawn Bayern <br /> [EMAIL PROTECTED] </address> +<address> +Karl von Randow +</address> Modified: jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Checkbox.java URL: http://svn.apache.org/viewvc/jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Checkbox.java?view=diff&rev=532548&r1=532547&r2=532548 ============================================================================== --- jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Checkbox.java (original) +++ jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Checkbox.java Wed Apr 25 17:10:28 2007 @@ -43,9 +43,12 @@ */ private String value; + private Boolean checked; + protected void init() { super.init(); value = null; + checked = null; } public int doStartTag() throws JspException { @@ -59,17 +62,21 @@ printAttributes(out); printAttribute(out, "value", value); - String[] values = findValues(); - if (values != null) { - String value = this.value != null ? this.value : DEFAULT_VALUE; - for (int i = 0; i < values.length; i++) { - if (values[i] != null && values[i].equals(value)) { - printAttribute(out, "checked", true); - break; + if (checked != null) { + printAttribute(out, "checked", checked.booleanValue()); + } else { + String[] values = findValues(); + if (values != null) { + String value = this.value != null ? this.value : DEFAULT_VALUE; + for (int i = 0; i < values.length; i++) { + if (values[i] != null && values[i].equals(value)) { + printAttribute(out, "checked", true); + break; + } } } } - + out.print(" />"); } catch (IOException ex) { throw new JspTagException(ex.getMessage()); @@ -111,20 +118,24 @@ this.value = value; } - public String getCheckedValue() { + public String getCurrentValue() { return super.getValue(); } - public void setCheckedValue(String value) { + public void setCurrentValue(String value) { super.setValue(value); } - public String[] getCheckedValues() { + public String[] getCurrentValues() { return super.getValueArray(); } - public void setCheckedValues(String[] values) { + public void setCurrentValues(String[] values) { super.setValueArray(values); + } + + public void setChecked(boolean checked) { + this.checked = checked ? Boolean.TRUE : Boolean.FALSE; } } Modified: jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Radio.java URL: http://svn.apache.org/viewvc/jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Radio.java?view=diff&rev=532548&r1=532547&r2=532548 ============================================================================== --- jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Radio.java (original) +++ jakarta/taglibs/proper/input/trunk/src/org/apache/taglibs/input/Radio.java Wed Apr 25 17:10:28 2007 @@ -40,6 +40,8 @@ * specifying what value the tag should tag (ie. what state it is in). */ private String value; + + private Boolean checked; protected void init() { super.init(); @@ -58,14 +60,18 @@ printAttributes(out); printAttribute(out, "value", value); - /* Note that radio buttons cannot support the array mode of findValue, - * as it is expected that there will be multiple radio elements with - * the same name on the page; but they all particpate to select a single - * value. - */ - String target = findValue(false); - if (target != null && target.equals(value)) { - printAttribute(out, "checked", true); + if (checked != null) { + printAttribute(out, "checked", checked.booleanValue()); + } else { + /* Note that radio buttons cannot support the array mode of findValue, + * as it is expected that there will be multiple radio elements with + * the same name on the page; but they all particpate to select a single + * value. + */ + String target = findValue(false); + if (target != null && target.equals(value)) { + printAttribute(out, "checked", true); + } } out.print(" />"); @@ -83,12 +89,16 @@ this.value = value; } - public String getCheckedValue() { + public String getCurrentValue() { return super.getValue(); } - public void setCheckedValue(String value) { + public void setCurrentValue(String value) { super.setValue(value); + } + + public void setChecked(boolean checked) { + this.checked = checked ? Boolean.TRUE : Boolean.FALSE; } } Copied: jakarta/taglibs/proper/input/trunk/xml/attributes/checked.xml (from r531155, jakarta/taglibs/proper/input/trunk/xml/attributes/checkedvalue.xml) URL: http://svn.apache.org/viewvc/jakarta/taglibs/proper/input/trunk/xml/attributes/checked.xml?view=diff&rev=532548&p1=jakarta/taglibs/proper/input/trunk/xml/attributes/checkedvalue.xml&r1=531155&p2=jakarta/taglibs/proper/input/trunk/xml/attributes/checked.xml&r2=532548 ============================================================================== --- jakarta/taglibs/proper/input/trunk/xml/attributes/checkedvalue.xml (original) +++ jakarta/taglibs/proper/input/trunk/xml/attributes/checked.xml Wed Apr 25 17:10:28 2007 @@ -1,15 +1,26 @@ <attribute> - <name>checkedValue</name> + <name>checked</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <description> + Whether this input element should be checked or not. This overrides + the checkedValue and all other means of determining whether the element + is checked or not. + </description> + <availability>1.2</availability> + </attribute> + <attribute> + <name>currentValue</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <!-- Optional attribute type for JSP 1.2 rtexprvalue <type>java.lang.String</type> --> <!-- Used for JSP 1.2 TLD and generating HTML docs --> - <description>The checked value for this input element. If this matches the value of this + <description>If the currentValue matches the value of this input element then the element is checked. The value is used if no bean is specified - or if the bean doesn't exist. The value overrides any request parameters or default value, - even if the value is null. Unless you require this functionality it is recommended that + or if the bean doesn't exist. The currentValue overrides any request parameters or default value, + even if the currentValue is null. Unless you require this functionality it is recommended that you use the "default" attribute instead so that the form can autopopulate from the request parameters.</description> <!-- Used for the HTML documentation only. Modified: jakarta/taglibs/proper/input/trunk/xml/input.xml URL: http://svn.apache.org/viewvc/jakarta/taglibs/proper/input/trunk/xml/input.xml?view=diff&rev=532548&r1=532547&r2=532548 ============================================================================== --- jakarta/taglibs/proper/input/trunk/xml/input.xml (original) +++ jakarta/taglibs/proper/input/trunk/xml/input.xml Wed Apr 25 17:10:28 2007 @@ -24,7 +24,7 @@ <!ENTITY attr-bean SYSTEM "attributes/bean.xml"> <!ENTITY attr-default SYSTEM "attributes/default.xml"> <!ENTITY attr-value SYSTEM "attributes/value.xml"> -<!ENTITY attr-checkedValue SYSTEM "attributes/checkedvalue.xml"> +<!ENTITY attr-checked SYSTEM "attributes/checked.xml"> ]> <document url="./input.xml"> @@ -807,7 +807,7 @@ </description> <availability>1.0</availability> </attribute> - &attr-checkedValue; + &attr-checked; &attr-bean; &attrs; @@ -897,16 +897,16 @@ </description> <availability>1.0</availability> </attribute> - &attr-checkedValue; + &attr-checked; <attribute> - <name>checkedValues</name> + <name>currentValues</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <!-- Optional attribute type for JSP 1.2 rtexprvalue <type>java.lang.String</type> --> <!-- Used for JSP 1.2 TLD and generating HTML docs --> - <description>As for "checkedValue" but takes an array of values. If both "checkedValue" and "checkedValues" + <description>As for "currentValue" but takes an array of values. If both "currentValue" and "currentValues" are provided they are concatenated.</description> <!-- Used for the HTML documentation only. Version of taglib when this attribute became available, --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]