myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject [myfaces-tobago] 02/02: clean up
Date Wed, 21 Oct 2020 11:18:31 GMT
This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 0a48490e3e33ab446cbeecec2099aadb2e2ed0eb
Author: Udo Schnurpfeil <udo.schnurpfeil@irian.eu>
AuthorDate: Wed Oct 21 13:16:01 2020 +0200

    clean up
    
    * using explicit methods instead of static utils
---
 .../myfaces/tobago/internal/component/AbstractUITreeNode.java     | 2 ++
 .../myfaces/tobago/internal/component/AbstractUITreeSelect.java   | 2 ++
 .../internal/renderkit/renderer/DecodingCommandRendererBase.java  | 3 +--
 .../internal/renderkit/renderer/DecodingInputRendererBase.java    | 4 +++-
 .../myfaces/tobago/internal/renderkit/renderer/FileRenderer.java  | 7 ++++++-
 .../tobago/internal/renderkit/renderer/HiddenRenderer.java        | 5 +++++
 .../myfaces/tobago/internal/renderkit/renderer/InRenderer.java    | 5 +++++
 .../myfaces/tobago/internal/renderkit/renderer/OutRenderer.java   | 5 +++++
 .../myfaces/tobago/internal/renderkit/renderer/RangeRenderer.java | 5 +++++
 .../renderkit/renderer/SelectBooleanCheckboxRenderer.java         | 8 ++++++--
 .../internal/renderkit/renderer/SelectManyRendererBase.java       | 8 ++++++--
 .../tobago/internal/renderkit/renderer/SelectOneRendererBase.java | 8 ++++++--
 .../myfaces/tobago/internal/renderkit/renderer/StarsRenderer.java | 5 +++++
 .../tobago/internal/renderkit/renderer/TabGroupRenderer.java      | 4 ----
 .../tobago/internal/renderkit/renderer/TextareaRenderer.java      | 5 +++++
 .../tobago/internal/renderkit/renderer/TreeNodeRenderer.java      | 2 +-
 .../tobago/internal/renderkit/renderer/TreeSelectRenderer.java    | 7 ++++---
 .../main/java/org/apache/myfaces/tobago/util/ComponentUtils.java  | 4 ++++
 18 files changed, 71 insertions(+), 18 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
index 0b4faf1..cac85c3 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
@@ -23,4 +23,6 @@ package org.apache.myfaces.tobago.internal.component;
  * {@link org.apache.myfaces.tobago.internal.taglib.component.TreeNodeTagDeclaration}
  */
 public abstract class AbstractUITreeNode extends AbstractUITreeNodeBase {
+
+  public abstract boolean isDisabled();
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeSelect.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeSelect.java
index 2cd0332..607e9db 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeSelect.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeSelect.java
@@ -50,4 +50,6 @@ public abstract class AbstractUITreeSelect extends UISelectBoolean implements
Vi
   public abstract String getLabel();
 
   public abstract boolean isShowCheckbox();
+
+  public abstract boolean isDisabled();
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecodingCommandRendererBase.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecodingCommandRendererBase.java
index 92366c5..46a51c2 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecodingCommandRendererBase.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecodingCommandRendererBase.java
@@ -21,7 +21,6 @@ package org.apache.myfaces.tobago.internal.renderkit.renderer;
 
 import org.apache.myfaces.tobago.internal.component.AbstractUICommandBase;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
-import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -36,7 +35,7 @@ public abstract class DecodingCommandRendererBase<T extends AbstractUICommandBas
   @Override
   public void decodeInternal(final FacesContext facesContext, final T component) {
 
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (component.isDisabled()) {
       return;
     }
     final String sourceId = facesContext.getExternalContext().getRequestParameterMap().get("javax.faces.source");
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecodingInputRendererBase.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecodingInputRendererBase.java
index c1d9131..f361c5d 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecodingInputRendererBase.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecodingInputRendererBase.java
@@ -42,7 +42,7 @@ public abstract class DecodingInputRendererBase<T extends UIComponent>
extends R
       return; // no decoding required
     }
 
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (isOutputOnly(component)) {
       return; // no decoding required
     }
 
@@ -63,6 +63,8 @@ public abstract class DecodingInputRendererBase<T extends UIComponent>
extends R
     decodeClientBehaviors(facesContext, component);
   }
 
+  protected abstract boolean isOutputOnly(T component);
+
   protected void setSubmittedValue(
           final FacesContext facesContext, final EditableValueHolder component, final String
newValue) {
     component.setSubmittedValue(newValue);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
index 798af8c..e578f65 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
@@ -57,6 +57,11 @@ public class FileRenderer<T extends AbstractUIFile>
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled() || component.isReadonly();
+  }
+
+  @Override
   public HtmlElements getComponentTag() {
     return HtmlElements.TOBAGO_FILE;
   }
@@ -73,7 +78,7 @@ public class FileRenderer<T extends AbstractUIFile>
 
   @Override
   public void decodeInternal(final FacesContext facesContext, final T component) {
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (isOutputOnly(component)) {
       return;
     }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/HiddenRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/HiddenRenderer.java
index 69100e8..3446d5b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/HiddenRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/HiddenRenderer.java
@@ -33,6 +33,11 @@ import java.io.IOException;
 public class HiddenRenderer<T extends AbstractUIHidden> extends DecodingInputRendererBase<T>
{
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled();
+  }
+
+  @Override
   public void encodeBeginInternal(final FacesContext facesContext, final T component) throws
IOException {
 
     final String clientId = component.getClientId(facesContext);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
index 4d87e70..96da884 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
@@ -55,6 +55,11 @@ public class InRenderer<T extends AbstractUIIn> extends MessageLayoutRendererBas
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled() || component.isReadonly();
+  }
+
+  @Override
   public HtmlElements getComponentTag() {
     return HtmlElements.TOBAGO_IN;
   }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/OutRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/OutRenderer.java
index 588339a..02353bc 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/OutRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/OutRenderer.java
@@ -40,6 +40,11 @@ import java.util.StringTokenizer;
 public class OutRenderer<T extends AbstractUIOut> extends MessageLayoutRendererBase<T>
{
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return true;
+  }
+
+  @Override
   public HtmlElements getComponentTag() {
     return HtmlElements.DIV;
   }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/RangeRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/RangeRenderer.java
index af3fb7f..b0e3da8 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/RangeRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/RangeRenderer.java
@@ -37,6 +37,11 @@ import java.io.IOException;
 public class RangeRenderer<T extends AbstractUIRange> extends MessageLayoutRendererBase<T>
{
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled() || component.isReadonly();
+  }
+
+  @Override
   public HtmlElements getComponentTag() {
     return HtmlElements.TOBAGO_RANGE;
   }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectBooleanCheckboxRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectBooleanCheckboxRenderer.java
index 0f2fce2..d8efa09 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectBooleanCheckboxRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectBooleanCheckboxRenderer.java
@@ -31,7 +31,6 @@ import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
-import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,9 +45,14 @@ public class SelectBooleanCheckboxRenderer<T extends AbstractUISelectBooleanChec
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled() || component.isReadonly();
+  }
+
+  @Override
   public void decodeInternal(final FacesContext facesContext, final T component) {
 
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (isOutputOnly(component)) {
       return;
     }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRendererBase.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRendererBase.java
index 896b79e..cfe68f9 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRendererBase.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRendererBase.java
@@ -21,7 +21,6 @@ package org.apache.myfaces.tobago.internal.renderkit.renderer;
 
 import org.apache.myfaces.tobago.internal.component.AbstractUISelectManyBase;
 import org.apache.myfaces.tobago.internal.util.ArrayUtils;
-import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,8 +59,13 @@ public abstract class SelectManyRendererBase<T extends AbstractUISelectManyBase>
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled() || component.isReadonly();
+  }
+
+  @Override
   public void decodeInternal(final FacesContext facesContext, final T component) {
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (isOutputOnly(component)) {
       return;
     }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRendererBase.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRendererBase.java
index a8453cd..f470133 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRendererBase.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRendererBase.java
@@ -20,7 +20,6 @@
 package org.apache.myfaces.tobago.internal.renderkit.renderer;
 
 import org.apache.myfaces.tobago.internal.component.AbstractUISelectOneBase;
-import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -32,8 +31,13 @@ public abstract class SelectOneRendererBase<T extends AbstractUISelectOneBase>
e
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled() || component.isReadonly();
+  }
+
+  @Override
   public void decodeInternal(final FacesContext facesContext, final T component) {
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (isOutputOnly(component)) {
       return;
     }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/StarsRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/StarsRenderer.java
index f7b307a..d4adfb8 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/StarsRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/StarsRenderer.java
@@ -35,6 +35,11 @@ import java.io.IOException;
 public class StarsRenderer<T extends AbstractUIStars> extends MessageLayoutRendererBase<T>
{
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled() || component.isReadonly();
+  }
+
+  @Override
   public HtmlElements getComponentTag() {
     return HtmlElements.TOBAGO_STARS;
   }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
index df03fba..3d59bef 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
@@ -115,10 +115,6 @@ public class TabGroupRenderer<T extends AbstractUITabGroup> extends
RendererBase
 
   @Override
   public void decodeInternal(final FacesContext facesContext, final T component) {
-    if (ComponentUtils.isOutputOnly(component)) {
-      return;
-    }
-
     final int oldIndex = component.getRenderedIndex();
 
     final String clientId = component.getClientId(facesContext);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TextareaRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TextareaRenderer.java
index c0fddf8..9622c79 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TextareaRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TextareaRenderer.java
@@ -45,6 +45,11 @@ import java.io.IOException;
 public class TextareaRenderer<T extends AbstractUITextarea> extends MessageLayoutRendererBase<T>
{
 
   @Override
+  protected boolean isOutputOnly(T component) {
+    return component.isDisabled() || component.isReadonly();
+  }
+
+  @Override
   public HtmlElements getComponentTag() {
     return HtmlElements.TOBAGO_TEXTAREA;
   }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeNodeRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeNodeRenderer.java
index 56ba361..9bb3d35 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeNodeRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeNodeRenderer.java
@@ -56,7 +56,7 @@ public class TreeNodeRenderer<T extends AbstractUITreeNode> extends
RendererBase
 
     super.decodeInternal(facesContext, component);
 
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (component.isDisabled()) {
       return;
     }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
index 2d5411c..6f51719 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
@@ -54,15 +54,16 @@ public class TreeSelectRenderer<T extends AbstractUITreeSelect>
extends Renderer
 
   @Override
   public void decodeInternal(final FacesContext facesContext, final T component) {
-    final AbstractUITreeNodeBase node = ComponentUtils.findAncestor(component, AbstractUITreeNodeBase.class);
-    final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
 
-    if (ComponentUtils.isOutputOnly(component)) {
+    if (component.isDisabled()) {
       return;
     }
 
+    final AbstractUITreeNodeBase node = ComponentUtils.findAncestor(component, AbstractUITreeNodeBase.class);
+    final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
     final String clientId = component.getClientId(facesContext);
     final String name;
+
     if (data.getSelectable().isSingle()) {
       name = getClientIdWithoutRowIndex(data, clientId);
     } else {
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
index 49e6343..338265b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
@@ -448,6 +448,10 @@ public final class ComponentUtils {
     return false;
   }
 
+  /**
+   * @deprecated since 5.0.0
+   */
+  @Deprecated
   public static boolean isOutputOnly(final UIComponent component) {
     return getBooleanAttribute(component, Attributes.disabled)
         || getBooleanAttribute(component, Attributes.readonly);


Mime
View raw message