From 99b59641398f39d062899499931ec3e8522c4120 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 26 Aug 2011 11:25:49 +0000 Subject: [PATCH] update Lazy interface --- .../google/gwt/query/client/LazyGQuery.java | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java index db0a4ada..90d66196 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java @@ -351,6 +351,11 @@ public interface LazyGQuery extends LazyBase{ */ LazyGQuery attr(String key, Function closure); + /** + * Set a single property to a value, on all matched elements. + */ + LazyGQuery attr(String key, boolean value); + /** * Set a single property to a value, on all matched elements. */ @@ -2133,15 +2138,48 @@ public interface LazyGQuery extends LazyBase{ * array of all values in multivalues elements use vals() * * When the first element is a radio-button and is not checked, then it looks - * for a the first checked radio-button that has the same name in the list of + * for the first checked radio-button that has the same name in the list of * matched elements. + * + * When there are not matched elements it returns null. */ String val(); /** - * Sets the value attribute of every matched element In the case of multivalue - * elements, all values are setted for other elements, only the first value is - * considered. + * Sets the value attribute of every matched element based in the return + * value of the function evaluated for this element. + * + * NOTE: in jquery the function receives the arguments in different + * way, first index and them the actual value, but we use the normal way + * in gquery Function, first the element and second the index. + */ + LazyGQuery val(Function f); + + /** + * Sets the 'value' attribute of every matched element, but + * does not set the checked flag to checkboxes or radiobuttons. + * + * If you wanted to set values in collections of checkboxes o radiobuttons + * use val(String[]) instead + */ + LazyGQuery val(String value); + + /** + * Sets the value of every matched element. + * + * There is a different behaviour depending on the element type: + *
    + *
  • select multiple: options whose value match any of the passed values will be set. + *
  • select single: the last option whose value matches any of the passed values will be set. + *
  • input radio: the last input whose value matches any of the passed values will be set. + *
  • input checkbox: inputs whose value match any of the passed values will be set. + *
  • textarea, button, and other input: value will set to a string result of joining with coma, all passed values + *
+ * + * NOTE: if you wanted call this function with just one parameter, you have to + * pass an array signature to avoid call the overloaded val(String) method: + * + * $(...).val(new String[]{"value"}); */ LazyGQuery val(String... values); -- 2.39.5