You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/05/08 05:30:23 UTC
svn commit: r942298 - in /click/trunk/click:
examples/src/org/apache/click/examples/page/control/CheckListDemo.java
framework/src/org/apache/click/control/Option.java
Author: sabob
Date: Sat May 8 03:30:22 2010
New Revision: 942298
URL: http://svn.apache.org/viewvc?rev=942298&view=rev
Log:
added more generic constructors for Option
Modified:
click/trunk/click/examples/src/org/apache/click/examples/page/control/CheckListDemo.java
click/trunk/click/framework/src/org/apache/click/control/Option.java
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/control/CheckListDemo.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/control/CheckListDemo.java?rev=942298&r1=942297&r2=942298&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/control/CheckListDemo.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/control/CheckListDemo.java Sat May 8 03:30:22 2010
@@ -39,13 +39,13 @@ public class CheckListDemo extends Borde
static {
List<Option> list = new ArrayList<Option>();
for (int i = 1; i <= 4; i++) {
- list.add(new Option(Integer.toString(i),
+ list.add(new Option(i,
"Tutam gallia deviso est in partes " + i));
}
STANDARD_OPTIONS = Collections.unmodifiableList(list);
for(int i = 1; i <= 6; i++) {
- SORTABLE_OPTIONS.add(new Option(Integer.toString(i),
+ SORTABLE_OPTIONS.add(new Option(i,
"Drag to sort me " + i));
}
}
Modified: click/trunk/click/framework/src/org/apache/click/control/Option.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Option.java?rev=942298&r1=942297&r2=942298&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/Option.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/Option.java Sat May 8 03:30:22 2010
@@ -22,6 +22,8 @@ import java.io.Serializable;
import java.util.List;
import org.apache.click.util.HtmlStringBuffer;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
/**
* Provides a select Option element: <option></option>.
@@ -116,23 +118,29 @@ public class Option implements Serializa
/**
* Create an Option with the given value and display label.
* <p/>
- * <b>Note:</b> the specified value will be converted to a String.
+ * <b>Note:</b> the specified value and label will be converted to a String.
*
* @param value the Option value
* @param label the Option display label
*/
- public Option(Object value, String label) {
+ public Option(Object value, Object label) {
this.value = value.toString();
- this.label = label;
+ if (label == null) {
+ this.label = "";
+ } else {
+ this.label = label.toString();
+ }
}
/**
* Create an Option with the given value. The value will also be used
* for the display label.
+ * <p/>
+ * <b>Note:</b> the specified value will be converted to a String.
*
* @param value the Option value and display label
*/
- public Option(String value) {
+ public Option(Object value) {
this(value, value);
}