You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/06/27 22:25:11 UTC

svn commit: r1354708 - in /myfaces/tobago/trunk/tobago-extension: tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/ tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/

Author: lofwyr
Date: Wed Jun 27 20:25:10 2012
New Revision: 1354708

URL: http://svn.apache.org/viewvc?rev=1354708&view=rev
Log:
TOBAGO-1167: <tx:menuCheckbox> and <tx:menuRadio> should have the attributes "id" and "fieldId"

Modified:
    myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java
    myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuCheckboxExtensionTag.java
    myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuRadioExtensionTag.java

Modified: myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java?rev=1354708&r1=1354707&r2=1354708&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java Wed Jun 27 20:25:10 2012
@@ -41,9 +41,11 @@ public abstract class TobagoMenuExtensio
 
   private Class subComponentLastType = Object.class;
   private Metadata subComponentMapper;
+  private TagAttribute fieldIdAttribute;
 
   public TobagoMenuExtensionHandler(ComponentConfig config) {
     super(config);
+    fieldIdAttribute = getAttribute("fieldId");
   }
 
   protected abstract String getSubComponentType();
@@ -68,7 +70,13 @@ public abstract class TobagoMenuExtensio
     Application application = faceletContext.getFacesContext().getApplication();
     UIViewRoot root = ComponentSupport.getViewRoot(faceletContext, parent);
     UIComponent component = application.createComponent(getSubComponentType());
-    component.setId(root.createUniqueId());
+    final String uid;
+    if (fieldIdAttribute !=  null) {
+      uid = fieldIdAttribute.getValue(faceletContext);
+    } else {
+      uid = root.createUniqueId();
+    }
+    component.setId(uid);
     component.setRendererType(getSubRendererType());
     setSubComponentAttributes(faceletContext, component);
     menuCommand.getFacets().put(getFacetName(), component);

Modified: myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuCheckboxExtensionTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuCheckboxExtensionTag.java?rev=1354708&r1=1354707&r2=1354708&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuCheckboxExtensionTag.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuCheckboxExtensionTag.java Wed Jun 27 20:25:10 2012
@@ -52,7 +52,7 @@ public class MenuCheckboxExtensionTag ex
   private javax.el.ValueExpression value;
 
   private MenuCommandTag menuCommandTag;
-  private SelectBooleanCheckboxTag selectBooleanCheckbox;
+  private SelectBooleanCheckboxTag inTag;
   private FacetTag facetTag;
   private javax.el.MethodExpression action;
   private javax.el.MethodExpression actionListener;
@@ -64,13 +64,17 @@ public class MenuCheckboxExtensionTag ex
   private javax.el.ValueExpression immediate;
   private javax.el.ValueExpression transition;
   private javax.el.ValueExpression renderedPartially;
+  private String fieldId;
 
   @Override
   public int doStartTag() throws JspException {
 
     menuCommandTag = new MenuCommandTag();
     menuCommandTag.setPageContext(pageContext);
-    menuCommandTag.setParent(getParent()); // ???
+    menuCommandTag.setParent(getParent());
+    if (id != null) {
+      menuCommandTag.setId(id);
+    }
     if (rendered != null) {
       menuCommandTag.setRendered(rendered);
     }
@@ -113,14 +117,18 @@ public class MenuCheckboxExtensionTag ex
     facetTag.setName(Facets.CHECKBOX);
 
     facetTag.doStartTag();
-    selectBooleanCheckbox = new SelectBooleanCheckboxTag();
-    selectBooleanCheckbox.setPageContext(pageContext);
+    inTag = new SelectBooleanCheckboxTag();
+    inTag.setPageContext(pageContext);
+    inTag.setParent(facetTag);
     if (value != null) {
-      selectBooleanCheckbox.setValue(value);
+      inTag.setValue(value);
+    }
+    if (fieldId != null) {
+      inTag.setId(fieldId);
     }
-    selectBooleanCheckbox.setParent(facetTag);
-    selectBooleanCheckbox.setJspId(jspId + PREFIX + idSuffix++);
-    selectBooleanCheckbox.doStartTag();
+    inTag.setJspId(jspId + PREFIX + idSuffix++);
+    inTag.doStartTag();
+
     return super.doStartTag();
   }
 
@@ -129,23 +137,44 @@ public class MenuCheckboxExtensionTag ex
 
     if (renderedPartially == null) {
       // Move attribute renderedPartially from selectOne to menuCommand component
-      UIComponent selectBooleanComponent = selectBooleanCheckbox.getComponentInstance();
+      UIComponent inComponent = inTag.getComponentInstance();
       AbstractUICommandBase command = (AbstractUICommandBase) menuCommandTag.getComponentInstance();
-      javax.el.ValueExpression expression = selectBooleanComponent.getValueExpression(Attributes.RENDERED_PARTIALLY);
+      javax.el.ValueExpression expression = inComponent.getValueExpression(Attributes.RENDERED_PARTIALLY);
       if (expression != null) {
         command.setValueExpression(Attributes.RENDERED_PARTIALLY, expression);
       } else {
-        Object renderedPartially = selectBooleanComponent.getAttributes().get(Attributes.RENDERED_PARTIALLY);
+        Object renderedPartially = inComponent.getAttributes().get(Attributes.RENDERED_PARTIALLY);
         command.setRenderedPartially(StringUtils.split((String) renderedPartially, ", "));
       }
     }
-    
-    selectBooleanCheckbox.doEndTag();
+
+    inTag.doEndTag();
     facetTag.doEndTag();
     menuCommandTag.doEndTag();
+
     return super.doEndTag();
   }
 
+  public void release() {
+    super.release();
+    rendered = null;
+    value = null;
+    action = null;
+    actionListener = null;
+    onclick = null;
+    link = null;
+    disabled = null;
+    binding = null;
+    label = null;
+    immediate = null;
+    transition = null;
+    renderedPartially = null;
+    fieldId = null;
+    menuCommandTag = null;
+    facetTag = null;
+    inTag = null;
+  }
+
   /**
    * Action to invoke when clicked.
    * This must be a MethodBinding or a String representing the application action to invoke when
@@ -278,22 +307,25 @@ public class MenuCheckboxExtensionTag ex
     this.renderedPartially = renderedPartially;
   }
 
-  public void release() {
-    super.release();
-    rendered = null;
-    value = null;
-    action = null;
-    actionListener = null;
-    onclick = null;
-    link = null;
-    disabled = null;
-    binding = null;
-    label = null;
-    immediate = null;
-    transition = null;
-    renderedPartially = null;
-    menuCommandTag = null;
-    facetTag = null;
-    selectBooleanCheckbox = null;
+  /**
+   * The component identifier for the input field component inside of the container.
+   * This value must be unique within the closest parent component that is a naming container.
+   */
+  @TagAttribute(rtexprvalue = true)
+  @UIComponentTagAttribute
+  public void setFieldId(String fieldId) {
+    this.fieldId = fieldId;
+  }
+
+  /**
+   * The component identifier for this component.
+   * This value must be unique within the closest parent component that is a naming container.
+   * For tx components the id will be set to the container (e. g. the panel).
+   * To set the id of the input field, you have to use the attribute "fieldId".
+   */
+  @TagAttribute(rtexprvalue = true)
+  @UIComponentTagAttribute
+  public void setId(String id) {
+    super.setId(id);
   }
 }

Modified: myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuRadioExtensionTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuRadioExtensionTag.java?rev=1354708&r1=1354707&r2=1354708&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuRadioExtensionTag.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-taglib-extension/src/main/java-jsf-1.2/org/apache/myfaces/tobago/internal/taglib/extension/MenuRadioExtensionTag.java Wed Jun 27 20:25:10 2012
@@ -57,7 +57,7 @@ public class MenuRadioExtensionTag exten
   private javax.el.ValueExpression value;
 
   private MenuCommandTag menuCommandTag;
-  private SelectOneRadioTag selectOneRadio;
+  private SelectOneRadioTag inTag;
   private FacetTag facetTag;
   private javax.el.MethodExpression action;
   private javax.el.MethodExpression actionListener;
@@ -70,6 +70,7 @@ public class MenuRadioExtensionTag exten
   private javax.el.ValueExpression transition;
   private javax.el.ValueExpression converter;
   private javax.el.ValueExpression renderedPartially;
+  private String fieldId;
 
   @Override
   public int doStartTag() throws JspException {
@@ -77,7 +78,9 @@ public class MenuRadioExtensionTag exten
     menuCommandTag = new MenuCommandTag();
     menuCommandTag.setPageContext(pageContext);
     menuCommandTag.setParent(getParent());
-
+    if (id != null) {
+      menuCommandTag.setId(id);
+    }
     if (rendered != null) {
       menuCommandTag.setRendered(rendered);
     }
@@ -120,17 +123,20 @@ public class MenuRadioExtensionTag exten
     facetTag.setName(Facets.RADIO);
 
     facetTag.doStartTag();
-    selectOneRadio = new SelectOneRadioTag();
-    selectOneRadio.setPageContext(pageContext);
-    selectOneRadio.setParent(facetTag);
+    inTag = new SelectOneRadioTag();
+    inTag.setPageContext(pageContext);
+    inTag.setParent(facetTag);
     if (converter != null) {
-      selectOneRadio.setConverter(converter);
+      inTag.setConverter(converter);
     }
     if (value != null) {
-      selectOneRadio.setValue(value);
+      inTag.setValue(value);
+    }
+    if (fieldId != null) {
+      inTag.setId(fieldId);
     }
-    selectOneRadio.setJspId(jspId + PREFIX + idSuffix++);
-    selectOneRadio.doStartTag();
+    inTag.setJspId(jspId + PREFIX + idSuffix++);
+    inTag.doStartTag();
 
     return super.doStartTag();
   }
@@ -140,18 +146,18 @@ public class MenuRadioExtensionTag exten
 
     if (renderedPartially == null) {
       // Move attribute renderedPartially from selectOne to menuCommand component
-      UIComponent selectOneComponent = selectOneRadio.getComponentInstance();
+      UIComponent inComponent = inTag.getComponentInstance();
       AbstractUICommandBase command = (AbstractUICommandBase) menuCommandTag.getComponentInstance();
-      javax.el.ValueExpression expression = selectOneComponent.getValueExpression(Attributes.RENDERED_PARTIALLY);
+      javax.el.ValueExpression expression = inComponent.getValueExpression(Attributes.RENDERED_PARTIALLY);
       if (expression != null) {
         command.setValueExpression(Attributes.RENDERED_PARTIALLY, expression);
       } else {
-        Object renderedPartially = selectOneComponent.getAttributes().get(Attributes.RENDERED_PARTIALLY);
+        Object renderedPartially = inComponent.getAttributes().get(Attributes.RENDERED_PARTIALLY);
         command.setRenderedPartially(StringUtils.split((String) renderedPartially, ", "));
       }
     }
 
-    selectOneRadio.doEndTag();
+    inTag.doEndTag();
     facetTag.doEndTag();
     menuCommandTag.doEndTag();
 
@@ -173,9 +179,10 @@ public class MenuRadioExtensionTag exten
     transition = null;
     converter = null;
     renderedPartially = null;
+    fieldId = null;
     menuCommandTag = null;
     facetTag = null;
-    selectOneRadio = null;
+    inTag = null;
   }
 
   /**
@@ -325,4 +332,26 @@ public class MenuRadioExtensionTag exten
   public void setRenderedPartially(javax.el.ValueExpression renderedPartially) {
     this.renderedPartially = renderedPartially;
   }
+
+  /**
+   * The component identifier for the input field component inside of the container.
+   * This value must be unique within the closest parent component that is a naming container.
+   */
+  @TagAttribute(rtexprvalue = true)
+  @UIComponentTagAttribute
+  public void setFieldId(String fieldId) {
+    this.fieldId = fieldId;
+  }
+
+  /**
+   * The component identifier for this component.
+   * This value must be unique within the closest parent component that is a naming container.
+   * For tx components the id will be set to the container (e. g. the panel).
+   * To set the id of the input field, you have to use the attribute "fieldId".
+   */
+  @TagAttribute(rtexprvalue = true)
+  @UIComponentTagAttribute
+  public void setId(String id) {
+    super.setId(id);
+  }
 }