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/02/04 17:43:53 UTC

svn commit: r1728506 - in /myfaces/tobago/branches/tobago-3.0.x: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/...

Author: lofwyr
Date: Thu Feb  4 16:43:52 2016
New Revision: 1728506

URL: http://svn.apache.org/viewvc?rev=1728506&view=rev
Log:
repair rendering of the <tc:hidden>

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIHidden.java
      - copied, changed from r1727334, myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java
Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/LabelLayout.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/HiddenTagDeclaration.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/HiddenRenderer.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/InputRendererBase.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/LabelLayoutRendererBase.java

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/LabelLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/LabelLayout.java?rev=1728506&r1=1728505&r2=1728506&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/LabelLayout.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/LabelLayout.java Thu Feb  4 16:43:52 2016
@@ -23,7 +23,50 @@ import javax.faces.context.FacesContext;
 
 public enum LabelLayout {
 
-  none, flexLeft, flexRight, top, segmentLeft, segmentRight, flowLeft, flowRight;
+  /**
+   * do not render the label
+   */
+  none,
+
+  /**
+   * flex layout: let the label be on the left side
+   */
+  flexLeft,
+
+  /**
+   * flex layout: let the label be on the right side
+   */
+  flexRight,
+
+  /**
+   * let the label be on the top of the element
+   */
+  top,
+
+  /**
+   * segment layout: let the label be on the left side
+   */
+  segmentLeft,
+
+  /**
+   * segment layout: let the label be on the right side
+   */
+  segmentRight,
+
+  /**
+   * flow layout: let the label be on the left side
+   */
+  flowLeft,
+
+  /**
+   * flow layout: let the label be on the right side
+   */
+  flowRight,
+
+  /**
+   * skip rendering the surrounding container.
+   */
+  skip;
 
   private static final String SEGMENT_TO_RENDER_KEY = LabelLayout.class.getName();
 

Copied: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIHidden.java (from r1727334, myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIHidden.java?p2=myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIHidden.java&p1=myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java&r1=1727334&r2=1728506&rev=1728506&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIHidden.java Thu Feb  4 16:43:52 2016
@@ -19,6 +19,9 @@
 
 package org.apache.myfaces.tobago.internal.component;
 
-public abstract class AbstractUIIn extends AbstractUIInput {
+import javax.faces.component.UIInput;
 
+public abstract class AbstractUIHidden extends UIInput {
+
+  public abstract boolean isDisabled();
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/HiddenTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/HiddenTagDeclaration.java?rev=1728506&r1=1728505&r2=1728506&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/HiddenTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/HiddenTagDeclaration.java Thu Feb  4 16:43:52 2016
@@ -37,7 +37,7 @@ import javax.faces.component.UIInput;
 @Tag(name = "hidden")
 @UIComponentTag(
     uiComponent = "org.apache.myfaces.tobago.component.UIHidden",
-    uiComponentBaseClass = "javax.faces.component.UIInput",
+    uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUIHidden",
     uiComponentFacesClass = "javax.faces.component.UIInput",
     componentFamily = UIInput.COMPONENT_FAMILY,
     rendererType = RendererTypes.HIDDEN,

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/HiddenRenderer.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/HiddenRenderer.java?rev=1728506&r1=1728505&r2=1728506&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/HiddenRenderer.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/HiddenRenderer.java Thu Feb  4 16:43:52 2016
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
 import org.apache.myfaces.tobago.component.UIHidden;
+import org.apache.myfaces.tobago.internal.component.AbstractUIHidden;
 import org.apache.myfaces.tobago.layout.Display;
 import org.apache.myfaces.tobago.renderkit.css.Style;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
@@ -38,13 +39,14 @@ public class HiddenRenderer extends Inpu
 
   protected void encodeBeginField(FacesContext facesContext, UIComponent component) throws IOException {
 
-    final String clientId = component.getClientId(facesContext);
-    final String value = RenderUtils.currentValue(component);
+    final AbstractUIHidden hidden = (AbstractUIHidden) component;
+    final String clientId = hidden.getClientId(facesContext);
+    final String value = RenderUtils.currentValue(hidden);
 
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
     writer.startElement(HtmlElements.INPUT);
-    if (component instanceof UIHidden && ((UIHidden) component).isDisabled()) {
+    if (hidden.isDisabled()) {
       writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.TEXT);
       final Style style = new Style();
       style.setDisplay(Display.none);
@@ -55,7 +57,7 @@ public class HiddenRenderer extends Inpu
     }
     writer.writeNameAttribute(clientId);
     writer.writeIdAttribute(clientId);
-    HtmlRendererUtils.writeDataAttributes(facesContext, writer, component);
+    HtmlRendererUtils.writeDataAttributes(facesContext, writer, hidden);
     writer.writeAttribute(HtmlAttributes.VALUE, value != null ? value : "", true);
     writer.endElement(HtmlElements.INPUT);
   }

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/InputRendererBase.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/InputRendererBase.java?rev=1728506&r1=1728505&r2=1728506&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/InputRendererBase.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/InputRendererBase.java Thu Feb  4 16:43:52 2016
@@ -45,17 +45,17 @@ public abstract class InputRendererBase
       return; // no decoding required
     }
 
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (ComponentUtils.isOutputOnly(input)) {
       return;
     }
 
-    final String clientId = component.getClientId(facesContext);
+    final String clientId = input.getClientId(facesContext);
 
     final Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
     if (requestParameterMap.containsKey(clientId)) {
       String newValue = requestParameterMap.get(clientId);
       if (LOG.isDebugEnabled()) {
-        final boolean password = ComponentUtils.getBooleanAttribute(component, Attributes.password);
+        final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.password);
         LOG.debug("clientId='{}'", clientId);
         LOG.debug("requestParameterMap.get(clientId)='{}'", StringUtils.toConfidentialString(newValue, password));
       }

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/LabelLayoutRendererBase.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/LabelLayoutRendererBase.java?rev=1728506&r1=1728505&r2=1728506&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/LabelLayoutRendererBase.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/LabelLayoutRendererBase.java Thu Feb  4 16:43:52 2016
@@ -49,7 +49,7 @@ public abstract class LabelLayoutRendere
 
     encodeBeginSurrounding(facesContext, component);
 
-    switch (((SupportsLabelLayout) component).getLabelLayout()) {
+    switch (getType(component)) {
       case segmentLeft:
         if (LabelLayout.getSegment(facesContext) == LabelLayout.segmentRight) {
           encodeBeginField(facesContext, component);
@@ -68,7 +68,8 @@ public abstract class LabelLayoutRendere
 
   @Override
   public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {
-    switch (((SupportsLabelLayout) component).getLabelLayout()) {
+
+    switch (getType(component)) {
       case segmentLeft:
         if (LabelLayout.getSegment(facesContext) == LabelLayout.segmentRight) {
           encodeEndField(facesContext, component);
@@ -105,7 +106,7 @@ public abstract class LabelLayoutRendere
     // - segmentRight (todo)
     // - flowLeft (todo)
     // - flowRight (todo)
-    final LabelLayout labelLayout = ((SupportsLabelLayout) component).getLabelLayout();
+    final LabelLayout labelLayout = getType(component);
     final CssItem divClass;
     switch (labelLayout) {
       case flexLeft:
@@ -163,7 +164,7 @@ public abstract class LabelLayoutRendere
   protected void encodeEndSurrounding(final FacesContext facesContext, final UIComponent component) throws IOException {
 
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-    final LabelLayout labelLayout = ((SupportsLabelLayout) component).getLabelLayout();
+    final LabelLayout labelLayout = getType(component);
 
     switch (labelLayout) {
       case flexRight:
@@ -193,4 +194,10 @@ public abstract class LabelLayoutRendere
     }
   }
 
+  private LabelLayout getType(UIComponent component) {
+    return component instanceof SupportsLabelLayout
+        ? ((SupportsLabelLayout) component).getLabelLayout()
+        : LabelLayout.skip;
+  }
+
 }