myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1571968 - in /myfaces/tobago/branches/tobago-3.0.x: ./ tobago-core/src/main/java/org/apache/myfaces/tobago/util/ tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ tobago-example/tobago-example-test/sr...
Date Wed, 26 Feb 2014 09:03:50 GMT
Author: lofwyr
Date: Wed Feb 26 09:03:49 2014
New Revision: 1571968

URL: http://svn.apache.org/r1571968
Log:
Merged from trunk
TOBAGO-1362: Support dynamic list of objects for f:selectItems

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/selectItem/list-of-objects.xhtml
      - copied unchanged from r1571193, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/selectItem/list-of-objects.xhtml
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/SelectItemUtils.java
      - copied unchanged from r1571193, myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/SelectItemUtils.java
Modified:
    myfaces/tobago/branches/tobago-3.0.x/   (props changed)
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SelectItemModel.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MenuCommandRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyListboxRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyShuttleRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneListboxRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneRadioRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java

Propchange: myfaces/tobago/branches/tobago-3.0.x/
------------------------------------------------------------------------------
  Merged /myfaces/tobago/trunk:r1571193

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
Wed Feb 26 09:03:49 2014
@@ -669,7 +669,10 @@ public final class ComponentUtils {
     valueBinding.setValue(context, value);
   }
 
-
+  /**
+   * @deprecated Since Tobago 2.0
+   */
+  @Deprecated
   public static boolean hasSelectedValue(final List<SelectItem> items, final Object
value) {
     for (final SelectItem item : items) {
       if (item.getValue().equals(value)) {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SelectItemModel.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SelectItemModel.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SelectItemModel.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SelectItemModel.java
Wed Feb 26 09:03:49 2014
@@ -32,21 +32,31 @@ public class SelectItemModel {
   private boolean switch1;
   private boolean switch2 = true;
 
-  private SelectItem[] availableCurrencies;
+  private final SelectItem[] availableCurrencies;
+
+  private final Currency[] availableCurrenciesAsObject;
 
   public SelectItemModel() {
-    availableCurrencies = new SelectItem[]{
-        new SelectItem(Currency.getInstance("JPY")),
-        new SelectItem(Currency.getInstance("TTD")),
-        new SelectItem(Currency.getInstance("USD")),
-        new SelectItem(Currency.getInstance("EUR")),
+    availableCurrenciesAsObject = new Currency[]{
+        Currency.getInstance("JPY"),
+        Currency.getInstance("TTD"),
+        Currency.getInstance("USD"),
+        Currency.getInstance("EUR")
     };
+    availableCurrencies = new SelectItem[availableCurrenciesAsObject.length];
+    for (int i = 0; i < availableCurrenciesAsObject.length; i++) {
+      availableCurrencies[i] = new SelectItem(availableCurrenciesAsObject[i]);
+    }
   }
 
   public SelectItem[] getAvailableCurrencies() {
     return availableCurrencies;
   }
 
+  public Currency[] getAvailableCurrenciesAsObject() {
+    return availableCurrenciesAsObject;
+  }
+
   public int getNumber() {
     return number;
   }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MenuCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MenuCommandRenderer.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MenuCommandRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MenuCommandRenderer.java
Wed Feb 26 09:03:49 2014
@@ -42,6 +42,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.JsonUtils;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.renderkit.util.SelectItemUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
@@ -52,7 +53,6 @@ import javax.faces.component.UISelectOne
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
-import java.util.List;
 
 /**
  * Does the decoding with parent class CommandRendererBase.
@@ -86,9 +86,8 @@ public class MenuCommandRenderer extends
       // radio menu
       final String clientId = command.getClientId(facesContext);
       final UISelectOne radio = (UISelectOne) command.getFacet(Facets.RADIO);
-      final List<SelectItem> items = RenderUtils.getSelectItems(radio);
       final String hiddenId = radio.getClientId(facesContext);
-      for (final SelectItem item : items) {
+      for (final SelectItem item : SelectItemUtils.iterator(facesContext, radio)) {
         final boolean checked = item.getValue().equals(radio.getValue());
         final String image = checked ? "image/MenuRadioChecked.gif" : null;
         final String labelText = item.getLabel();

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyListboxRenderer.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyListboxRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyListboxRenderer.java
Wed Feb 26 09:03:49 2014
@@ -26,7 +26,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
-import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.renderkit.util.SelectItemUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
@@ -36,7 +36,6 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
-import java.util.List;
 
 public class SelectManyListboxRenderer extends SelectManyRendererBase {
 
@@ -57,9 +56,9 @@ public class SelectManyListboxRenderer e
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
     final String id = select.getClientId(facesContext);
-    final List<SelectItem> items = RenderUtils.getSelectItems(select);
+    final Iterable<SelectItem> items = SelectItemUtils.iterator(facesContext, select);
     final boolean readonly = select.isReadonly();
-    final boolean disabled = items.size() == 0 || select.isDisabled() || readonly;
+    final boolean disabled = !items.iterator().hasNext() || select.isDisabled() || readonly;
 
     final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
     writer.startElement(HtmlElements.SELECT, select);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyShuttleRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyShuttleRenderer.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyShuttleRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyShuttleRenderer.java
Wed Feb 26 09:03:49 2014
@@ -29,7 +29,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.HtmlButtonTypes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
-import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.renderkit.util.SelectItemUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
@@ -37,7 +37,6 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
-import java.util.List;
 
 public class SelectManyShuttleRenderer extends SelectManyRendererBase {
 
@@ -73,8 +72,8 @@ public class SelectManyShuttleRenderer e
       style.setHeight(style.getHeight().subtract(labelHeight));
       style.setTop(style.getTop().add(labelHeight));
     }
-    final List<SelectItem> items = RenderUtils.getSelectItems(select);
-    final boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();
+    final Iterable<SelectItem> items = SelectItemUtils.iterator(facesContext, select);
+    final boolean disabled = !items.iterator().hasNext() || select.isDisabled() || select.isReadonly();
 
     final String unselectedLabel = select.getUnselectedLabel();
     if (unselectedLabel != null) {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
Wed Feb 26 09:03:49 2014
@@ -27,7 +27,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
-import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.renderkit.util.SelectItemUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
@@ -37,7 +37,6 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
-import java.util.List;
 
 public class SelectOneChoiceRenderer extends SelectOneRendererBase {
 
@@ -58,9 +57,9 @@ public class SelectOneChoiceRenderer ext
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
     final String id = select.getClientId(facesContext);
-    final List<SelectItem> items = RenderUtils.getSelectItems(select);
+    final Iterable<SelectItem> items = SelectItemUtils.iterator(facesContext, select);
     final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
-    final boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();
+    final boolean disabled = !items.iterator().hasNext() || select.isDisabled() || select.isReadonly();
 
     writer.startElement(HtmlElements.SELECT, select);
     writer.writeNameAttribute(id);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneListboxRenderer.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneListboxRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneListboxRenderer.java
Wed Feb 26 09:03:49 2014
@@ -26,7 +26,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
-import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.renderkit.util.SelectItemUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
@@ -36,7 +36,6 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
-import java.util.List;
 
 public class SelectOneListboxRenderer extends SelectOneRendererBase {
 
@@ -57,8 +56,8 @@ public class SelectOneListboxRenderer ex
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
     final String id = select.getClientId(facesContext);
-    final List<SelectItem> items = RenderUtils.getSelectItems(select);
-    final boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();
+    final Iterable<SelectItem> items = SelectItemUtils.iterator(facesContext, select);
+    final boolean disabled = !items.iterator().hasNext() || select.isDisabled() || select.isReadonly();
 
     writer.startElement(HtmlElements.SELECT, select);
     writer.writeNameAttribute(id);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneRadioRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneRadioRenderer.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneRadioRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneRadioRenderer.java
Wed Feb 26 09:03:49 2014
@@ -31,6 +31,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.renderkit.util.SelectItemUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
@@ -39,7 +40,6 @@ import javax.faces.component.UISelectOne
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
-import java.util.List;
 
 public class SelectOneRadioRenderer extends SelectOneRendererBase {
 
@@ -56,7 +56,7 @@ public class SelectOneRadioRenderer exte
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
     final String id = select.getClientId(facesContext);
-    final List<SelectItem> items = RenderUtils.getItemsToRender(select);
+    final Iterable<SelectItem> items = SelectItemUtils.iterator(facesContext, select);
     final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
     final boolean disabled = select.isDisabled();
     final boolean readonly = select.isReadonly();
@@ -124,8 +124,12 @@ public class SelectOneRadioRenderer exte
     if (select.isInline()) {
       return heightOfOne;
     } else {
-      final List<SelectItem> items = RenderUtils.getItemsToRender((UISelectOne) component);
-      return heightOfOne.multiply(items.size());
+      final Iterable<SelectItem> items = SelectItemUtils.iterator(facesContext, (UISelectOne)
component);
+      int count = 0;
+      for(SelectItem ignored : items) {
+        count++;
+      }
+      return heightOfOne.multiply(count);
     }
   }
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java
Wed Feb 26 09:03:49 2014
@@ -48,6 +48,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.JsonUtils;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.renderkit.util.SelectItemUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.util.CreateComponentUtils;
 import org.apache.myfaces.tobago.util.FacetUtils;
@@ -59,7 +60,6 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
-import java.util.List;
 
 public abstract class ToolBarRendererBase extends LayoutComponentRendererBase {
 
@@ -121,15 +121,15 @@ public abstract class ToolBarRendererBas
       final FacesContext facesContext, final UIToolBar toolBar, final AbstractUICommandBase
command,
       final TobagoResponseWriter writer, Measure width) throws IOException {
 
-    final List<SelectItem> items;
+    final Iterable<SelectItem> items;
 
     UIMenuSelectOne radio = (UIMenuSelectOne) command.getFacet(Facets.RADIO);
     if (radio == null) {
-      items = RenderUtils.getSelectItems(command);
+      items = SelectItemUtils.iterator(facesContext, command);
       radio = CreateComponentUtils.createUIMenuSelectOneFacet(facesContext, command);
       radio.setId(facesContext.getViewRoot().createUniqueId());
     } else {
-      items = RenderUtils.getSelectItems(radio);
+      items = SelectItemUtils.iterator(facesContext, radio);
     }
 
     if (radio != null) {
@@ -138,7 +138,7 @@ public abstract class ToolBarRendererBas
       final Object value = radio.getValue();
 
       String currentValue = "";
-      boolean markFirst = !ComponentUtils.hasSelectedValue(items, value);
+      boolean markFirst = !hasSelectedValue(items, value);
       final String radioId = radio.getClientId(facesContext);
       for (final SelectItem item : items) {
         final String labelText = item.getLabel();
@@ -605,4 +605,14 @@ public abstract class ToolBarRendererBas
   public boolean getRendersChildren() {
     return true;
   }
+
+  private boolean hasSelectedValue(final Iterable<SelectItem> items, final Object value)
{
+    for (final SelectItem item : items) {
+      if (item.getValue().equals(value)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
Wed Feb 26 09:03:49 2014
@@ -348,14 +348,13 @@ public final class HtmlRendererUtils {
     return title;
   }
 
-  public static void renderSelectItems(final UIInput component, final List<SelectItem>
items, final Object[] values,
+  public static void renderSelectItems(final UIInput component, final Iterable<SelectItem>
items, final Object[] values,
       final TobagoResponseWriter writer, final FacesContext facesContext) throws IOException
{
     renderSelectItems(component, items, values, null, writer, facesContext);
-
   }
 
   public static void renderSelectItems(
-      final UIInput component, final List<SelectItem> items, final Object[] values,
final Boolean onlySelected,
+      final UIInput component, final Iterable<SelectItem> items, final Object[] values,
final Boolean onlySelected,
       final TobagoResponseWriter writer, final FacesContext facesContext) throws IOException
{
 
     if (LOG.isDebugEnabled()) {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java?rev=1571968&r1=1571967&r2=1571968&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
Wed Feb 26 09:03:49 2014
@@ -245,8 +245,8 @@ public class RenderUtils {
     final List<SelectItem> items = new ArrayList<SelectItem>(indices.length);
 
     if (selectItems.size() != 0) {
-      for (final int indice : indices) {
-        items.add(selectItems.get(indice));
+      for (final int index : indices) {
+        items.add(selectItems.get(index));
       }
     } else {
       LOG.warn("No items found! rendering dummies instead!");
@@ -287,6 +287,9 @@ public class RenderUtils {
     return currentValue;
   }
 
+  /**
+   * @deprecated Please use this method with facesContext parameter
+   */
   public static List<SelectItem> getSelectItems(final UIComponent component) {
 
     final ArrayList<SelectItem> list = new ArrayList<SelectItem>();



Mime
View raw message