You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/10/09 12:27:14 UTC

svn commit: r583096 - /myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java

Author: bommel
Date: Tue Oct  9 03:27:14 2007
New Revision: 583096

URL: http://svn.apache.org/viewvc?rev=583096&view=rev
Log:
(TOBAGO-464) Create a real tx extension taglib for facelets

Modified:
    myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java

Modified: myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java?rev=583096&r1=583095&r2=583096&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java (original)
+++ myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java Tue Oct  9 03:27:14 2007
@@ -26,11 +26,11 @@
 import org.apache.myfaces.tobago.TobagoConstants;
 import org.apache.myfaces.tobago.component.SupportsMarkup;
 import org.apache.myfaces.tobago.component.UIGridLayout;
+import org.apache.myfaces.tobago.component.UIInput;
 import org.apache.myfaces.tobago.component.UILabel;
 import org.apache.myfaces.tobago.component.UIPanel;
-import org.apache.myfaces.tobago.component.UIInput;
-import org.apache.myfaces.tobago.facelets.SupportsMarkupRule;
 import org.apache.myfaces.tobago.facelets.SuggestMethodRule;
+import org.apache.myfaces.tobago.facelets.SupportsMarkupRule;
 
 import javax.el.ELException;
 import javax.faces.FacesException;
@@ -38,6 +38,7 @@
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
 import java.io.IOException;
+import java.util.List;
 
 /*
  * Date: Jul 31, 2007
@@ -95,10 +96,13 @@
     addGridLayout(faceletContext, panel, root);
 
     addLabel(faceletContext, panel, root);
+    String uid = root.createUniqueId();
+    if (checkForAlreadyCreated(panel, uid)) {
+      return;
+    }
 
     UIComponent input = application.createComponent(getSubComponentType());
     input.setRendererType(getSubRendererType());
-    String uid = root.createUniqueId();
     input.setId(uid);
 
     setAttributes(faceletContext, input);
@@ -108,10 +112,14 @@
 
 
   private void addLabel(FaceletContext faceletContext, UIComponent panel, UIViewRoot root) {
+    String uid = root.createUniqueId();
+    if (checkForAlreadyCreated(panel, uid)) {
+      return;
+    }
     Application application = faceletContext.getFacesContext().getApplication();
     UILabel label = (UILabel) application.createComponent(UILabel.COMPONENT_TYPE);
     label.setRendererType(TobagoConstants.RENDERER_TYPE_LABEL);
-    label.setId(root.createUniqueId());
+    label.setId(uid);
     label.getAttributes().put(TobagoConstants.ATTR_FOR, "@auto");
     if (tipAttribute != null) {
       label.setTip(tipAttribute.getValue(faceletContext));
@@ -120,6 +128,17 @@
       label.setValue(labelAttribute.getValue(faceletContext));
     }
     panel.getChildren().add(label);
+  }
+
+  private boolean checkForAlreadyCreated(UIComponent panel, String uid) {
+    if (panel.getChildCount() > 0) {
+      for (UIComponent child:(List<UIComponent>) panel.getChildren()) {
+        if (uid.equals(child.getId())) {
+          return true;
+        }
+      }
+    }
+    return false;
   }
 
   private void addGridLayout(FaceletContext faceletContext, UIComponent panel, UIViewRoot root) {