You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2022/12/05 11:57:13 UTC

[myfaces-tobago] branch main updated: feat(selectManyList): rename inline to expanded

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
     new 29988d2c4b feat(selectManyList): rename inline to expanded
29988d2c4b is described below

commit 29988d2c4bb9f608290cfe5d034fc7631590a541
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Mon Dec 5 12:15:28 2022 +0100

    feat(selectManyList): rename inline to expanded
    
    * better naming
    
    Issue: TOBAGO-2159
---
 .../component/AbstractUISelectManyList.java        |  2 +-
 .../renderkit/renderer/SelectManyListRenderer.java | 34 ++++++++++++----------
 .../component/SelectManyListTagDeclaration.java    |  4 +--
 .../internal/taglib/declaration/IsExpanded.java    | 32 ++++++++++++++++++++
 .../80-selectManyList/SelectManyList.xhtml         | 14 ++++-----
 5 files changed, 60 insertions(+), 26 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyList.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyList.java
index 69b039006d..87b0a069a6 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyList.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyList.java
@@ -60,7 +60,7 @@ public abstract class AbstractUISelectManyList extends AbstractUISelectManyBase
 
   public abstract boolean isDisabled();
 
-  public abstract boolean isInline();
+  public abstract boolean isExpanded();
 
   public boolean isError() {
     final FacesContext facesContext = FacesContext.getCurrentInstance();
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRenderer.java
index f2f7fffe02..b34a777893 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRenderer.java
@@ -21,7 +21,6 @@ package org.apache.myfaces.tobago.internal.renderkit.renderer;
 
 import jakarta.faces.context.FacesContext;
 import jakarta.faces.model.SelectItem;
-import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.internal.component.AbstractUISelectManyList;
 import org.apache.myfaces.tobago.internal.util.ArrayUtils;
 import org.apache.myfaces.tobago.internal.util.HtmlRendererUtils;
@@ -76,8 +75,7 @@ public class SelectManyListRenderer<T extends AbstractUISelectManyList> extends
     final List<SelectItem> items = SelectItemUtils.getItemList(facesContext, component);
     final boolean disabled = !items.iterator().hasNext() || component.isDisabled() || component.isReadonly();
     final String filter = component.getFilter();
-    final boolean inline = component.isInline();
-    final Markup markup = component.getMarkup();
+    final boolean expanded = component.isExpanded();
     final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, component);
     final Integer tabIndex = component.getTabIndex();
 
@@ -85,11 +83,12 @@ public class SelectManyListRenderer<T extends AbstractUISelectManyList> extends
 
     writer.startElement(HtmlElements.DIV);
     writer.writeClassAttribute(
-        inline ? BootstrapClass.LIST_GROUP : BootstrapClass.DROPDOWN,
-        inline ? BootstrapClass.borderColor(ComponentUtils.getMaximumSeverity(component)) : null);
+        expanded ? BootstrapClass.LIST_GROUP : BootstrapClass.DROPDOWN,
+        expanded ? BootstrapClass.borderColor(ComponentUtils.getMaximumSeverity(component)) : null);
 
-    encodeSelectField(facesContext, component, clientId, fieldId, filterId, filter, disabled, inline, title, tabIndex);
-    encodeOptions(facesContext, component, items, clientId, inline, disabled);
+    encodeSelectField(facesContext, component,
+        clientId, fieldId, filterId, filter, disabled, expanded, title, tabIndex);
+    encodeOptions(facesContext, component, items, clientId, expanded, disabled);
 
     writer.endElement(HtmlElements.DIV);
   }
@@ -101,7 +100,8 @@ public class SelectManyListRenderer<T extends AbstractUISelectManyList> extends
     writer.writeAttribute(CustomAttributes.FILTER, input.getFilter(), true);
   }
 
-  private void encodeHiddenSelect(final FacesContext facesContext, final T component, final List<SelectItem> items,
+  private void encodeHiddenSelect(
+      final FacesContext facesContext, final T component, final List<SelectItem> items,
       final String clientId, final String selectedId, final boolean disabled) throws IOException {
     final TobagoResponseWriter writer = getResponseWriter(facesContext);
 
@@ -119,9 +119,10 @@ public class SelectManyListRenderer<T extends AbstractUISelectManyList> extends
     writer.endElement(HtmlElements.SELECT);
   }
 
-  private void encodeSelectField(final FacesContext facesContext, final T component,
+  private void encodeSelectField(
+      final FacesContext facesContext, final T component,
       final String clientId, final String fieldId, final String filterId, final String filter, final boolean disabled,
-      final boolean inline, final String title, final Integer tabIndex) throws IOException {
+      final boolean expanded, final String title, final Integer tabIndex) throws IOException {
     final TobagoResponseWriter writer = getResponseWriter(facesContext);
 
     writer.startElement(HtmlElements.DIV);
@@ -129,10 +130,10 @@ public class SelectManyListRenderer<T extends AbstractUISelectManyList> extends
     writer.writeNameAttribute(clientId);
     HtmlRendererUtils.writeDataAttributes(facesContext, writer, component);
     writer.writeClassAttribute(
-        inline ? BootstrapClass.FORM_CONTROL : BootstrapClass.FORM_SELECT,
+        expanded ? BootstrapClass.FORM_CONTROL : BootstrapClass.FORM_SELECT,
         TobagoClass.SELECT__FIELD,
-        inline ? BootstrapClass.LIST_GROUP_ITEM : BootstrapClass.DROPDOWN_TOGGLE,
-        inline ? null : BootstrapClass.borderColor(ComponentUtils.getMaximumSeverity(component)),
+        expanded ? BootstrapClass.LIST_GROUP_ITEM : BootstrapClass.DROPDOWN_TOGGLE,
+        expanded ? null : BootstrapClass.borderColor(ComponentUtils.getMaximumSeverity(component)),
         component.getCustomClass());
     writer.writeAttribute(HtmlAttributes.TITLE, title, true);
     writer.writeAttribute(Arias.EXPANDED, Boolean.FALSE.toString(), false);
@@ -153,14 +154,15 @@ public class SelectManyListRenderer<T extends AbstractUISelectManyList> extends
     writer.endElement(HtmlElements.DIV);
   }
 
-  private void encodeOptions(final FacesContext facesContext, final T component, final List<SelectItem> items,
-      final String clientId, final boolean inline, final boolean disabled) throws IOException {
+  private void encodeOptions(
+      final FacesContext facesContext, final T component, final List<SelectItem> items,
+      final String clientId, final boolean expanded, final boolean disabled) throws IOException {
     final TobagoResponseWriter writer = getResponseWriter(facesContext);
 
     writer.startElement(HtmlElements.DIV);
     writer.writeClassAttribute(
         TobagoClass.OPTIONS,
-        inline ? BootstrapClass.LIST_GROUP_ITEM : BootstrapClass.DROPDOWN_MENU);
+        expanded ? BootstrapClass.LIST_GROUP_ITEM : BootstrapClass.DROPDOWN_MENU);
     writer.writeNameAttribute(clientId);
 
     writer.startElement(HtmlElements.TABLE);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyListTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyListTagDeclaration.java
index 3ca103c0f1..ad0d7bea28 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyListTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyListTagDeclaration.java
@@ -44,8 +44,8 @@ import org.apache.myfaces.tobago.internal.taglib.declaration.HasValidator;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasValidatorMessage;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasValueChangeListener;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsDisabled;
+import org.apache.myfaces.tobago.internal.taglib.declaration.IsExpanded;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsFocus;
-import org.apache.myfaces.tobago.internal.taglib.declaration.IsInline;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsReadonly;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsRendered;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsRequiredForSelect;
@@ -82,7 +82,7 @@ public interface SelectManyListTagDeclaration
     extends HasId, IsDisabled, IsRendered, HasBinding, HasTip, HasHelp,
     IsReadonly, HasConverter, IsRequiredForSelect, HasLabel, HasValidator, HasValueChangeListener, HasLabelLayout,
     HasValidatorMessage, HasConverterMessage, HasRequiredMessageForSelect, HasTabIndex, IsFocus, IsVisual,
-    HasAutoSpacing, HasFilter, IsInline {
+    HasAutoSpacing, HasFilter, IsExpanded {
 
   /**
    * The value of the multi select.
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsExpanded.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsExpanded.java
new file mode 100644
index 0000000000..7b9180edad
--- /dev/null
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsExpanded.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.internal.taglib.declaration;
+
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+
+public interface IsExpanded {
+  /**
+   * Flag indicating this component should rendered as an expanded element.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
+  void setExpanded(String expanded);
+}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/80-selectManyList/SelectManyList.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/80-selectManyList/SelectManyList.xhtml
index 69294f9ec2..6027033c36 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/80-selectManyList/SelectManyList.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/80-selectManyList/SelectManyList.xhtml
@@ -27,22 +27,22 @@
   <tc:badge markup="warning"
             value="Preliminary feature, may be subject to change!"/><br/>
 
-  <tc:section label="not inline / no filter">
+  <tc:section label="not expanded / no filter">
     <tc:selectManyList id="selected1" value="#{selectManyListController.selected1}">
       <tc:selectItems value="#{selectManyListController.planets}"
                       var="planet" itemLabel="#{planet.name}" itemValue="#{planet}"/>
     </tc:selectManyList>
   </tc:section>
 
-  <tc:section label="inline / no filter">
-    <tc:selectManyList id="selected2" value="#{selectManyListController.selected2}" inline="true">
+  <tc:section label="expanded / no filter">
+    <tc:selectManyList id="selected2" value="#{selectManyListController.selected2}" expanded="true">
       <tc:selectItems value="#{selectManyListController.planets}"
                       var="planet" itemLabel="#{planet.name}" itemValue="#{planet}"/>
     </tc:selectManyList>
     <tc:button label="Submit"/>
   </tc:section>
 
-  <tc:section label="not inline / with filter">
+  <tc:section label="not expanded / with filter">
     <tc:selectManyList id="selected3" value="#{selectManyListController.selected3}" filter="contains">
       <tc:selectItems value="#{selectManyListController.planets}"
                       var="planet" itemLabel="#{planet.name}" itemValue="#{planet}"/>
@@ -50,8 +50,8 @@
     <tc:button label="Submit"/>
   </tc:section>
 
-  <tc:section label="inline / with filter:">
-    <tc:selectManyList id="selected4" value="#{selectManyListController.selected4}" filter="contains" inline="true">
+  <tc:section label="expanded / with filter:">
+    <tc:selectManyList id="selected4" value="#{selectManyListController.selected4}" filter="contains" expanded="true">
       <tc:selectItems value="#{selectManyListController.planets}"
                       var="planet" itemLabel="#{planet.name}" itemValue="#{planet}"/>
     </tc:selectManyList>
@@ -68,7 +68,7 @@
       <f:ajax render="filter" execute="filter"/>
     </tc:selectOneRadio>
     <tc:selectManyList id="selected5" value="#{selectManyListController.selected5}"
-                       filter="#{selectManyListController.filterType}" inline="true">
+                       filter="#{selectManyListController.filterType}" expanded="true">
       <tc:selectItems value="#{selectManyListController.names}"
                       var="name" itemLabel="#{name}" itemValue="#{name}"/>
       <tc:style maxHeight="300px"/>