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 2016/11/11 10:45:07 UTC

svn commit: r1769271 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-example/tobago-example-demo/src/main/webapp/ tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/rend...

Author: lofwyr
Date: Fri Nov 11 10:45:07 2016
New Revision: 1769271

URL: http://svn.apache.org/viewvc?rev=1769271&view=rev
Log:
TOBAGO-1622: Menus aren't AJAX updateable.
[developed with hnoeth]

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java?rev=1769271&r1=1769270&r2=1769271&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java Fri Nov 11 10:45:07 2016
@@ -19,8 +19,10 @@
 
 package org.apache.myfaces.tobago.internal.component;
 
+import org.apache.myfaces.tobago.component.SupportFieldId;
 import org.apache.myfaces.tobago.component.SupportsAccessKey;
 import org.apache.myfaces.tobago.component.Visual;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -28,9 +30,10 @@ import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
 import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
 
 public abstract class AbstractUICommand extends AbstractUICommandBase
-    implements SupportsAccessKey, Visual, ClientBehaviorHolder {
+    implements SupportsAccessKey, Visual, ClientBehaviorHolder, SupportFieldId {
 
   private static final Logger LOG = LoggerFactory.getLogger(AbstractUICommand.class);
 
@@ -56,4 +59,9 @@ public abstract class AbstractUICommand
 
   @Override
   public abstract String getLabel();
+
+  @Override
+  public String getFieldId(final FacesContext facesContext) {
+    return getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "command";
+  }
 }

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml?rev=1769271&r1=1769270&r2=1769271&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml Fri Nov 11 10:45:07 2016
@@ -82,7 +82,7 @@
 
           <!-- TBD: this is not nice: can we put tc:out or tc:label into the menu?
           or we do that with a popup, oder a lighter variant of a popup -->
-          <tc:link omit="true" label="Info">
+          <tc:link omit="true" label="Info" id="headerInfo">
             <tc:link omit="true" label="Theme: #{clientConfigController.localizedTheme}" disabled="true"/>
             <tc:link omit="true" label="Locale: #{clientConfigController.localizedLocale}"/>
             <tc:link omit="true" label="Project Stage: #{tobagoContext.tobagoConfig.projectStage}"/>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java?rev=1769271&r1=1769270&r2=1769271&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java Fri Nov 11 10:45:07 2016
@@ -23,7 +23,6 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.internal.component.AbstractUIButton;
 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.apache.myfaces.tobago.internal.component.AbstractUIFormBase;
-import org.apache.myfaces.tobago.internal.component.AbstractUILinks;
 import org.apache.myfaces.tobago.internal.util.AccessKeyLogger;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
 import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
@@ -62,11 +61,13 @@ public abstract class CommandRendererBas
     final LabelWithAccessKey label = new LabelWithAccessKey(command);
     final boolean link = command.getLink() != null && !disabled;
     final String target = command.getTarget();
+    final boolean parentOfCommands = command.isParentOfCommands();
 
     final TobagoResponseWriter writer = getResponseWriter(facesContext);
 
-    if (needsExtraSpanElement(command)) {
+    if (parentOfCommands) { // extra span
       writer.startElement(HtmlElements.SPAN);
+      writer.writeIdAttribute(clientId);
       if (component instanceof AbstractUIButton) { // todo: check if we should differ here
         writer.writeClassAttribute(BootstrapClass.BTN_GROUP);
       } else {
@@ -80,7 +81,11 @@ public abstract class CommandRendererBas
       writer.startElement(HtmlElements.BUTTON);
       writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON);
     }
-    writer.writeIdAttribute(clientId);
+    if (parentOfCommands) {
+      writer.writeIdAttribute(command.getFieldId(facesContext));
+    } else {
+      writer.writeIdAttribute(clientId);
+    }
     writer.writeNameAttribute(clientId);
     writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
 
@@ -110,7 +115,7 @@ public abstract class CommandRendererBas
     writer.writeStyleAttribute(command.getStyle());
 
     final List<CssItem> cssItems = new ArrayList<CssItem>();
-    if (command.isParentOfCommands()) {
+    if (parentOfCommands) {
       // XXX BootstrapClass.NAV_LINK should only be shown inside of UICommands or UIButtons
       cssItems.add(BootstrapClass.DROPDOWN_TOGGLE);
       writer.writeAttribute(DataAttributes.TOGGLE, "dropdown", false);
@@ -165,7 +170,7 @@ public abstract class CommandRendererBas
       writer.endElement(HtmlElements.BUTTON);
     }
 
-    if (command.isParentOfCommands()) {
+    if (parentOfCommands) {
       writer.startElement(HtmlElements.UL);
       writer.writeClassAttribute(BootstrapClass.DROPDOWN_MENU);
       writer.writeAttribute(HtmlAttributes.ROLE, HtmlRoleValues.MENU.toString(), false);
@@ -210,9 +215,6 @@ public abstract class CommandRendererBas
 
     if (command.isParentOfCommands()) {
       writer.endElement(HtmlElements.UL);
-    }
-
-    if (needsExtraSpanElement(command)) {
       writer.endElement(HtmlElements.SPAN);
     }
   }
@@ -221,12 +223,4 @@ public abstract class CommandRendererBas
       final FacesContext facesContext, final AbstractUICommand command, final List<CssItem> collected) {
   }
 
-  /**
-   * We need an extra SPAN element with position: relative or absolute for positioning the dropdown
-   */
-  private boolean needsExtraSpanElement(AbstractUICommand command) {
-    return !(command.getParent() instanceof AbstractUICommand) // only needed for top elements
-        && !(command.getParent() instanceof AbstractUILinks) // not needed inside of tc:links
-        && command.isParentOfCommands(); // only needed for sub-menus
-  }
 }