myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r1087964 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/util/ tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/
Date Sat, 02 Apr 2011 06:41:08 GMT
Author: bommel
Date: Sat Apr  2 06:41:08 2011
New Revision: 1087964

URL: http://svn.apache.org/viewvc?rev=1087964&view=rev
Log:
(TOBAGO-110) After validation of a mandatory field there is no jump to the correct tab in
tabGroup

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1087964&r1=1087963&r2=1087964&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
Sat Apr  2 06:41:08 2011
@@ -42,6 +42,7 @@ import javax.faces.application.Applicati
 import javax.faces.application.FacesMessage;
 import javax.faces.component.ActionSource;
 import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
 import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIGraphic;
@@ -885,4 +886,31 @@ public class ComponentUtils {
     return null;
   }
 
+  public static boolean hasChildrenWithMessages(FacesContext facesContext, NamingContainer
 container) {
+    if (container instanceof UIComponent) {
+      String clientId = ((UIComponent) container).getClientId(facesContext);
+      for (Iterator ids = facesContext.getClientIdsWithMessages(); ids.hasNext();) {
+        String id = (String) ids.next();
+        if (id.startsWith(clientId)) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  public static String[] getChildrenWithMessages(FacesContext facesContext, NamingContainer
 container) {
+    if (container instanceof UIComponent) {
+      List<String> clientIds = new ArrayList<String>();
+      String clientId = ((UIComponent) container).getClientId(facesContext);
+      for (Iterator ids = facesContext.getClientIdsWithMessages(); ids.hasNext();) {
+        String id = (String) ids.next();
+        if (id.startsWith(clientId)) {
+          clientIds.add(id);
+        }
+      }
+      return clientIds.toArray(new String[clientIds.size()]);
+    }
+    return ArrayUtils.EMPTY_STRING_ARRAY;
+  }
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=1087964&r1=1087963&r2=1087964&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
Sat Apr  2 06:41:08 2011
@@ -189,6 +189,11 @@ public class TabGroupRenderer extends La
           } else {
             tab.setCurrentMarkup(tab.getCurrentMarkup().remove(Markup.SELECTED));
           }
+          if (ComponentUtils.hasChildrenWithMessages(facesContext, tab)) {
+            tab.setCurrentMarkup(tab.getCurrentMarkup().add(Markup.ERROR));
+          } else {
+            tab.setCurrentMarkup(tab.getCurrentMarkup().remove(Markup.ERROR));
+          }
           writer.startElement(HtmlElements.DIV, tab);
           writer.writeClassAttribute(Classes.create(tab));
           writer.writeAttribute(HtmlAttributes.TABGROUPINDEX, index);



Mime
View raw message