You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2023/05/11 15:09:54 UTC
[myfaces-tobago] branch main updated (f442abb670 -> 4d293be4fb)
This is an automated email from the ASF dual-hosted git repository.
bommel pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
from f442abb670 build(theme): rebuild after fixing dropdown key events
new af85a901eb fix(selectOne|ManyList): Support for ajax onchange
new d066cf77a1 fix(selectOne|ManyList): Support for ajax onchange rebuild js issue: TOBAGO-2217
new 06b47ba84c fix(selectOne|ManyList): Support for ajax onchange apache header
new 4d293be4fb fix(selectOne|ManyList): Support for ajax onchange apache header
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../myfaces/tobago/component/SupportFieldId.java | 4 ++
.../component/AbstractUISelectManyList.java | 5 +++
.../component/AbstractUISelectOneList.java | 5 +++
.../renderer/TobagoClientBehaviorRenderer.java | 2 +-
.../internal/config/AbstractTobagoTestBase.java | 10 +++++
...st.java => SelectManyListRendererUnitTest.java} | 24 ++++++----
...est.java => SelectOneListRendererUnitTest.java} | 24 ++++++----
.../selectManyList/selectManyListAjax.html | 50 +++++++++++++++++++++
.../renderer/selectOneList/selectOneListAjax.html | 51 ++++++++++++++++++++++
.../resources/tobago-config-for-unit-tests.xml | 10 +++++
.../tobago-theme-standard/src/main/js/tobago.js | 8 ++--
.../src/main/js/tobago.js.map | 2 +-
.../src/main/ts/tobago-select-many-list.ts | 2 +
.../src/main/ts/tobago-select-one-list.ts | 2 +
14 files changed, 175 insertions(+), 24 deletions(-)
copy tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/{SelectOneChoiceRendererUnitTest.java => SelectManyListRendererUnitTest.java} (65%)
copy tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/{SelectOneChoiceRendererUnitTest.java => SelectOneListRendererUnitTest.java} (65%)
create mode 100644 tobago-core/src/test/resources/renderer/selectManyList/selectManyListAjax.html
create mode 100644 tobago-core/src/test/resources/renderer/selectOneList/selectOneListAjax.html
[myfaces-tobago] 02/04: fix(selectOne|ManyList): Support for ajax onchange rebuild js issue: TOBAGO-2217
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bommel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit d066cf77a121b5eb2d650d7ae5c97c6c942ffa1a
Author: Bernd Bohmann <bo...@apache.org>
AuthorDate: Thu May 11 12:34:50 2023 +0200
fix(selectOne|ManyList): Support for ajax onchange
rebuild js
issue: TOBAGO-2217
---
tobago-theme/tobago-theme-standard/src/main/js/tobago.js | 8 ++++----
tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
index 79ffea5f9e..35ed18c104 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
@@ -1,19 +1,19 @@
-!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e;!function(e){e.ACTIVE="active",e.AUTOCOMPLETE="autocomplete",e.AUTOCOMPLETE_INPUT="autocomplete-input",e.COLLAPSE="collapse",e.COLLAPSING="collapsing",e.D_NONE="d-none",e.DISABLED="disabled",e.DROPDOWN="dropdown",e.DROPDOWN_ITEM="dropdown-item",e.DROPDOWN_MENU="dropdown-menu",e.DROPDOWN_MENU_END="dropdown-menu-end",e.FIXED_BOTTOM="fixed-bottom",e.INPUT_GROUP="input-group",e.POSITION_RELATIVE= [...]
+!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e;!function(e){e.ACTIVE="active",e.AUTOCOMPLETE="autocomplete",e.AUTOCOMPLETE_INPUT="autocomplete-input",e.COLLAPSE="collapse",e.COLLAPSING="collapsing",e.D_NONE="d-none",e.DISABLED="disabled",e.DROPDOWN="dropdown",e.DROPDOWN_ITEM="dropdown-item",e.DROPDOWN_MENU="dropdown-menu",e.DROPDOWN_MENU_END="dropdown-menu-end",e.FIXED_BOTTOM="fixed-bottom",e.INPUT_GROUP="input-group",e.POSITION_RELATIVE= [...]
/*!
* Bootstrap v5.2.3 (https://getbootstrap.com/)
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
-const Me="transitionend",Pe=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let s=e.getAttribute("href");if(!s||!s.includes("#")&&!s.startsWith("."))return null;s.includes("#")&&!s.startsWith("#")&&(s=`#${s.split("#")[1]}`),t=s&&"#"!==s?s.trim():null}return t},Be=e=>{const t=Pe(e);return t&&document.querySelector(t)?t:null},$e=e=>{const t=Pe(e);return t?document.querySelector(t):null},He=e=>{e.dispatchEvent(new Event(Me))},qe=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&( [...]
+const Me="transitionend",Pe=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let s=e.getAttribute("href");if(!s||!s.includes("#")&&!s.startsWith("."))return null;s.includes("#")&&!s.startsWith("#")&&(s=`#${s.split("#")[1]}`),t=s&&"#"!==s?s.trim():null}return t},Be=e=>{const t=Pe(e);return t&&document.querySelector(t)?t:null},$e=e=>{const t=Pe(e);return t?document.querySelector(t):null},He=e=>{e.dispatchEvent(new Event(Me))},qe=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&( [...]
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
- */const qi=window,ji=qi.trustedTypes,Wi=ji?ji.createPolicy("lit-html",{createHTML:e=>e}):void 0,Fi="$lit$",zi=`lit$${(Math.random()+"").slice(9)}$`,Ui="?"+zi,Vi=`<${Ui}>`,Gi=document,Yi=()=>Gi.createComment(""),Xi=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Ji=Array.isArray,Ki="[ \t\n\f\r]",Qi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Zi=/-->/g,eo=/>/g,to=RegExp(`>|${Ki}(?:([^\\s"'>=/]+)(${Ki}*=${Ki}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),so=/'/g,no=/"/g,io=/ [...]
+ */const qi=window,ji=qi.trustedTypes,Wi=ji?ji.createPolicy("lit-html",{createHTML:e=>e}):void 0,Fi="$lit$",zi=`lit$${(Math.random()+"").slice(9)}$`,Ui="?"+zi,Vi=`<${Ui}>`,Gi=document,Yi=()=>Gi.createComment(""),Xi=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Ji=Array.isArray,Ki="[ \t\n\f\r]",Qi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Zi=/-->/g,eo=/>/g,to=RegExp(`>|${Ki}(?:([^\\s"'>=/]+)(${Ki}*=${Ki}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),so=/'/g,no=/"/g,io=/ [...]
<button type='button'
class='tobago-button btn btn-secondary badge' aria-label='deselect ${e}'
${s>0?" tabindex='"+String(s)+"'":""}
@click="${this.removeBadge.bind(this)}"
@focus="${this.focusEvent.bind(this)}"
- @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){const t=e.target.closest(".btn-group").dataset.tobagoValue,s=this.hiddenSelect.querySelector(`[value="${t}"]`);s.selected=!1;const n=this.selectField.querySelector(`[data-tobago-value="${t}"]`),i=n.previousElementSibling,o="SPAN"===n.nextElementSibling.tagName?n.nextElementSibling:null;i?i.querySelector("button.btn.badge").focus():o?o.querySelector("button.btn.badge").focus():(this.filterInput.dis [...]
+ @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){const t=e.target.closest(".btn-group").dataset.tobagoValue,s=this.hiddenSelect.querySelector(`[value="${t}"]`);s.selected=!1;const n=this.selectField.querySelector(`[data-tobago-value="${t}"]`),i=n.previousElementSibling,o="SPAN"===n.nextElementSibling.tagName?n.nextElementSibling:null;i?i.querySelector("button.btn.badge").focus():o?o.querySelector("button.btn.badge").focus():(this.filterInput.dis [...]
//# sourceMappingURL=tobago.js.map
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
index de51198666..b22b8697cd 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
@@ -1 +1 @@
-{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.ts","../ts/tobago-bar.ts","../../../../node_modules/@popperjs/core/lib/enums.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../../../../node_modules/@popperjs/core/lib/utils/getBasePlacement.j [...]
\ No newline at end of file
+{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.ts","../ts/tobago-bar.ts","../../../../node_modules/@popperjs/core/lib/enums.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../../../../node_modules/@popperjs/core/lib/utils/getBasePlacement.j [...]
\ No newline at end of file
[myfaces-tobago] 01/04: fix(selectOne|ManyList): Support for ajax onchange
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bommel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit af85a901ebd553f596b1fd3199079adca3f8473d
Author: Bernd Bohmann <bo...@apache.org>
AuthorDate: Thu May 11 12:33:58 2023 +0200
fix(selectOne|ManyList): Support for ajax onchange
issue: TOBAGO-2217
---
.../myfaces/tobago/component/SupportFieldId.java | 4 +++
.../component/AbstractUISelectManyList.java | 5 +++
.../component/AbstractUISelectOneList.java | 5 +++
.../renderer/TobagoClientBehaviorRenderer.java | 2 +-
.../internal/config/AbstractTobagoTestBase.java | 10 ++++++
.../renderer/SelectManyListRendererUnitTest.java | 41 ++++++++++++++++++++++
.../renderer/SelectOneListRendererUnitTest.java | 41 ++++++++++++++++++++++
.../selectManyList/selectManyListAjax.html | 33 +++++++++++++++++
.../renderer/selectOneList/selectOneListAjax.html | 34 ++++++++++++++++++
.../resources/tobago-config-for-unit-tests.xml | 10 ++++++
.../src/main/ts/tobago-select-many-list.ts | 2 ++
.../src/main/ts/tobago-select-one-list.ts | 2 ++
12 files changed, 188 insertions(+), 1 deletion(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/SupportFieldId.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/SupportFieldId.java
index 3205c79233..eea260a3b1 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/SupportFieldId.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/SupportFieldId.java
@@ -24,4 +24,8 @@ import jakarta.faces.context.FacesContext;
public interface SupportFieldId {
String getFieldId(FacesContext facesContext);
+
+ default String getFieldIdForBehavior(FacesContext facesContext) {
+ return getFieldId(facesContext);
+ }
}
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 87b0a069a6..0b8b99794a 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
@@ -56,6 +56,11 @@ public abstract class AbstractUISelectManyList extends AbstractUISelectManyBase
return getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "field";
}
+ @Override
+ public String getFieldIdForBehavior(FacesContext facesContext) {
+ return getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "selected";
+ }
+
public abstract Integer getTabIndex();
public abstract boolean isDisabled();
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneList.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneList.java
index 5ae6226f3f..9a8fb3a376 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneList.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneList.java
@@ -30,6 +30,11 @@ public abstract class AbstractUISelectOneList extends AbstractUISelectOneBase im
return getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "field";
}
+ @Override
+ public String getFieldIdForBehavior(FacesContext facesContext) {
+ return getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "selected";
+ }
+
public abstract String getFilter();
public abstract boolean isExpanded();
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
index c901cd5038..a114d0dd8f 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
@@ -87,7 +87,7 @@ public class TobagoClientBehaviorRenderer extends jakarta.faces.render.ClientBeh
final Collection<String> render = ajaxBehavior.getRender();
clientId = uiComponent.getClientId(facesContext);
if (uiComponent instanceof SupportFieldId) {
- fieldId = ((SupportFieldId) uiComponent).getFieldId(facesContext);
+ fieldId = ((SupportFieldId) uiComponent).getFieldIdForBehavior(facesContext);
}
executeIds = ComponentUtils.evaluateClientIds(facesContext, uiComponent, execute.toArray(new String[0]));
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java
index 72f1010306..815c2dc319 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java
@@ -53,9 +53,11 @@ import org.apache.myfaces.tobago.component.UISelectBooleanCheckbox;
import org.apache.myfaces.tobago.component.UISelectBooleanToggle;
import org.apache.myfaces.tobago.component.UISelectItem;
import org.apache.myfaces.tobago.component.UISelectManyCheckbox;
+import org.apache.myfaces.tobago.component.UISelectManyList;
import org.apache.myfaces.tobago.component.UISelectManyListbox;
import org.apache.myfaces.tobago.component.UISelectManyShuttle;
import org.apache.myfaces.tobago.component.UISelectOneChoice;
+import org.apache.myfaces.tobago.component.UISelectOneList;
import org.apache.myfaces.tobago.component.UISelectOneRadio;
import org.apache.myfaces.tobago.component.UISelectReference;
import org.apache.myfaces.tobago.component.UISeparator;
@@ -93,9 +95,11 @@ import org.apache.myfaces.tobago.internal.renderkit.renderer.SegmentLayoutRender
import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectBooleanCheckboxRenderer;
import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectBooleanToggleRenderer;
import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectManyCheckboxRenderer;
+import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectManyListRenderer;
import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectManyListboxRenderer;
import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectManyShuttleRenderer;
import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectOneChoiceRenderer;
+import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectOneListRenderer;
import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectOneRadioRenderer;
import org.apache.myfaces.tobago.internal.renderkit.renderer.SelectReferenceRenderer;
import org.apache.myfaces.tobago.internal.renderkit.renderer.SeparatorRenderer;
@@ -184,9 +188,11 @@ public abstract class AbstractTobagoTestBase extends AbstractJsfTestCase {
application.addComponent(Tags.selectBooleanToggle.componentType(), UISelectBooleanToggle.class.getName());
application.addComponent(Tags.selectManyCheckbox.componentType(), UISelectManyCheckbox.class.getName());
application.addComponent(Tags.selectManyListbox.componentType(), UISelectManyListbox.class.getName());
+ application.addComponent(Tags.selectManyList.componentType(), UISelectManyList.class.getName());
application.addComponent(Tags.selectManyShuttle.componentType(), UISelectManyShuttle.class.getName());
application.addComponent(Tags.selectOneRadio.componentType(), UISelectOneRadio.class.getName());
application.addComponent(Tags.selectOneChoice.componentType(), UISelectOneChoice.class.getName());
+ application.addComponent(Tags.selectOneList.componentType(), UISelectOneList.class.getName());
application.addComponent(Tags.selectReference.componentType(), UISelectReference.class.getName());
application.addComponent(Tags.separator.componentType(), UISeparator.class.getName());
application.addComponent(Tags.sheet.componentType(), UISheet.class.getName());
@@ -236,12 +242,16 @@ public abstract class AbstractTobagoTestBase extends AbstractJsfTestCase {
new SelectManyCheckboxRenderer<UISelectManyCheckbox>());
renderKit.addRenderer(UISelectManyListbox.COMPONENT_FAMILY, RendererTypes.SELECT_MANY_LISTBOX,
new SelectManyListboxRenderer<UISelectManyListbox>());
+ renderKit.addRenderer(UISelectManyList.COMPONENT_FAMILY, RendererTypes.SELECT_MANY_LIST,
+ new SelectManyListRenderer<UISelectManyList>());
renderKit.addRenderer(UISelectManyListbox.COMPONENT_FAMILY, RendererTypes.SELECT_MANY_SHUTTLE,
new SelectManyShuttleRenderer<UISelectManyShuttle>());
renderKit.addRenderer(UISelectOneRadio.COMPONENT_FAMILY, RendererTypes.SELECT_ONE_RADIO,
new SelectOneRadioRenderer<UISelectOneRadio>());
renderKit.addRenderer(UISelectOneChoice.COMPONENT_FAMILY, RendererTypes.SELECT_ONE_CHOICE,
new SelectOneChoiceRenderer<UISelectOneChoice>());
+ renderKit.addRenderer(UISelectOneList.COMPONENT_FAMILY, RendererTypes.SELECT_ONE_LIST,
+ new SelectOneListRenderer<UISelectOneList>());
renderKit.addRenderer(UISelectReference.COMPONENT_FAMILY, RendererTypes.SELECT_REFERENCE,
new SelectReferenceRenderer<UISelectReference>());
renderKit.addRenderer(UISeparator.COMPONENT_FAMILY, RendererTypes.SEPARATOR, new SeparatorRenderer<UISeparator>());
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRendererUnitTest.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRendererUnitTest.java
new file mode 100644
index 0000000000..3e1b3d8cc6
--- /dev/null
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRendererUnitTest.java
@@ -0,0 +1,41 @@
+package org.apache.myfaces.tobago.internal.renderkit.renderer;
+
+import jakarta.faces.component.behavior.AjaxBehavior;
+import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.component.Tags;
+import org.apache.myfaces.tobago.component.UISelectItem;
+import org.apache.myfaces.tobago.component.UISelectManyList;
+import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+public class SelectManyListRendererUnitTest extends RendererTestBase {
+
+ @Test
+ public void ajax() throws IOException {
+ final UISelectManyList c = (UISelectManyList) ComponentUtils.createComponent(
+ facesContext, Tags.selectManyList.componentType(), RendererTypes.SelectManyList, "id");
+ final UISelectItem i1 = (UISelectItem) ComponentUtils.createComponent(
+ facesContext, Tags.selectItem.componentType(), null, "i1");
+ i1.setItemLabel("Stratocaster");
+ i1.setItemValue("Stratocaster");
+ c.getChildren().add(i1);
+ final UISelectItem i2 = (UISelectItem) ComponentUtils.createComponent(
+ facesContext, Tags.selectItem.componentType(), null, "i2");
+ i2.setItemLabel("Telecaster");
+ i2.setItemValue("Telecaster");
+ c.getChildren().add(i2);
+ final AjaxBehavior behavior =
+ (AjaxBehavior) facesContext.getApplication().createBehavior(AjaxBehavior.BEHAVIOR_ID);
+ behavior.setExecute(Arrays.asList("textarea"));
+ behavior.setRender(Arrays.asList("panel"));
+ c.addClientBehavior("change", behavior);
+
+ c.encodeAll(facesContext);
+
+ Assertions.assertEquals(loadHtml("renderer/selectManyList/selectManyListAjax.html"), formattedResult());
+ }
+}
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneListRendererUnitTest.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneListRendererUnitTest.java
new file mode 100644
index 0000000000..be516ba2f8
--- /dev/null
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneListRendererUnitTest.java
@@ -0,0 +1,41 @@
+package org.apache.myfaces.tobago.internal.renderkit.renderer;
+
+import jakarta.faces.component.behavior.AjaxBehavior;
+import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.component.Tags;
+import org.apache.myfaces.tobago.component.UISelectItem;
+import org.apache.myfaces.tobago.component.UISelectOneList;
+import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+public class SelectOneListRendererUnitTest extends RendererTestBase {
+
+ @Test
+ public void ajax() throws IOException {
+ final UISelectOneList c = (UISelectOneList) ComponentUtils.createComponent(
+ facesContext, Tags.selectOneList.componentType(), RendererTypes.SelectOneList, "id");
+ final UISelectItem i1 = (UISelectItem) ComponentUtils.createComponent(
+ facesContext, Tags.selectItem.componentType(), null, "i1");
+ i1.setItemLabel("Stratocaster");
+ i1.setItemValue("Stratocaster");
+ c.getChildren().add(i1);
+ final UISelectItem i2 = (UISelectItem) ComponentUtils.createComponent(
+ facesContext, Tags.selectItem.componentType(), null, "i2");
+ i2.setItemLabel("Telecaster");
+ i2.setItemValue("Telecaster");
+ c.getChildren().add(i2);
+ final AjaxBehavior behavior =
+ (AjaxBehavior) facesContext.getApplication().createBehavior(AjaxBehavior.BEHAVIOR_ID);
+ behavior.setExecute(Arrays.asList("textarea"));
+ behavior.setRender(Arrays.asList("panel"));
+ c.addClientBehavior("change", behavior);
+
+ c.encodeAll(facesContext);
+
+ Assertions.assertEquals(loadHtml("renderer/selectOneList/selectOneListAjax.html"), formattedResult());
+ }
+}
diff --git a/tobago-core/src/test/resources/renderer/selectManyList/selectManyListAjax.html b/tobago-core/src/test/resources/renderer/selectManyList/selectManyListAjax.html
new file mode 100644
index 0000000000..5eb4f78f72
--- /dev/null
+++ b/tobago-core/src/test/resources/renderer/selectManyList/selectManyListAjax.html
@@ -0,0 +1,33 @@
+<tobago-select-many-list id='id' class='tobago-auto-spacing'>
+ <select id='id::selected' name='id' class='d-none' multiple='multiple'>
+ <option value='Stratocaster'>Stratocaster
+ </option>
+ <option value='Telecaster'>Telecaster
+ </option></select>
+ <div class='dropdown'>
+ <div id='id::field' name='id' class='form-select tobago-select-field dropdown-toggle' aria-expanded='false'>
+ <input type='search' id='id::filter' class='tobago-filter form-control' autocomplete='off' readonly='readonly'>
+ </div>
+ <div class='tobago-options tobago-dropdown-menu' name='id'>
+ <table class='table table-hover table-sm'>
+ <tbody>
+ <tr data-tobago-value='Stratocaster' tabindex='-1'>
+ <td value='Stratocaster'>Stratocaster
+ </td>
+ </tr>
+ <tr data-tobago-value='Telecaster' tabindex='-1'>
+ <td value='Telecaster'>Telecaster
+ </td>
+ </tr>
+ </tbody>
+ <tfoot>
+ <tr class='tobago-no-entries d-none'>
+ <td>---
+ </td>
+ </tr>
+ </tfoot>
+ </table>
+ </div>
+ </div>
+ <tobago-behavior event='change' client-id='id' field-id='id::selected' execute='id'></tobago-behavior>
+</tobago-select-many-list>
diff --git a/tobago-core/src/test/resources/renderer/selectOneList/selectOneListAjax.html b/tobago-core/src/test/resources/renderer/selectOneList/selectOneListAjax.html
new file mode 100644
index 0000000000..44abf9d2b5
--- /dev/null
+++ b/tobago-core/src/test/resources/renderer/selectOneList/selectOneListAjax.html
@@ -0,0 +1,34 @@
+<tobago-select-one-list id='id' class='tobago-auto-spacing'>
+ <select id='id::selected' name='id' class='d-none'>
+ <option value='Stratocaster'>Stratocaster
+ </option>
+ <option value='Telecaster'>Telecaster
+ </option></select>
+ <div class='dropdown'>
+ <div id='id::field' name='id' class='form-select tobago-select-field dropdown-toggle' aria-expanded='false'>
+ <span></span>
+ <input type='search' id='id::filter' class='tobago-filter form-control' autocomplete='off' readonly='readonly'>
+ </div>
+ <div class='tobago-options tobago-dropdown-menu' name='id'>
+ <table class='table table-hover table-sm'>
+ <tbody>
+ <tr data-tobago-value='Stratocaster' tabindex='-1'>
+ <td value='Stratocaster'>Stratocaster
+ </td>
+ </tr>
+ <tr data-tobago-value='Telecaster' tabindex='-1'>
+ <td value='Telecaster'>Telecaster
+ </td>
+ </tr>
+ </tbody>
+ <tfoot>
+ <tr class='tobago-no-entries d-none'>
+ <td>---
+ </td>
+ </tr>
+ </tfoot>
+ </table>
+ </div>
+ </div>
+ <tobago-behavior event='change' client-id='id' field-id='id::selected' execute='id'></tobago-behavior>
+</tobago-select-one-list>
diff --git a/tobago-core/src/test/resources/tobago-config-for-unit-tests.xml b/tobago-core/src/test/resources/tobago-config-for-unit-tests.xml
index 047f70b834..3d9d467159 100644
--- a/tobago-core/src/test/resources/tobago-config-for-unit-tests.xml
+++ b/tobago-core/src/test/resources/tobago-config-for-unit-tests.xml
@@ -79,6 +79,11 @@
<attribute name="messagePosition" default="buttonRight"/>
<attribute name="helpPosition" default="buttonRight"/>
</tag>
+ <tag name="selectManyList">
+ <attribute name="labelLayout" default="flexLeft"/>
+ <attribute name="messagePosition" default="buttonRight"/>
+ <attribute name="helpPosition" default="buttonRight"/>
+ </tag>
<tag name="selectManyShuttle">
<attribute name="labelLayout" default="flexLeft"/>
<attribute name="messagePosition" default="buttonRight"/>
@@ -94,6 +99,11 @@
<attribute name="messagePosition" default="buttonRight"/>
<attribute name="helpPosition" default="buttonRight"/>
</tag>
+ <tag name="selectOneList">
+ <attribute name="labelLayout" default="flexLeft"/>
+ <attribute name="messagePosition" default="buttonRight"/>
+ <attribute name="helpPosition" default="buttonRight"/>
+ </tag>
<tag name="selectOneRadio">
<attribute name="labelLayout" default="flexLeft"/>
<attribute name="messagePosition" default="buttonRight"/>
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many-list.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many-list.ts
index 6d8b896004..a13aa46026 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many-list.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many-list.ts
@@ -62,6 +62,8 @@ class SelectManyList extends SelectListBase {
const option: HTMLOptionElement = this.hiddenSelect.querySelector(`[value="${itemValue}"]`);
option.selected = !option.selected;
this.sync(option);
+ const e = new Event("change");
+ this.hiddenSelect.dispatchEvent(e);
}
private sync(option: HTMLOptionElement) {
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-one-list.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-one-list.ts
index 1302d5aca7..07389aaf34 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-one-list.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-one-list.ts
@@ -83,6 +83,8 @@ class SelectOneList extends SelectListBase {
option.selected = true;
this.filterInput.value = null;
this.sync();
+ const e = new Event("change");
+ this.hiddenSelect.dispatchEvent(e);
}
private sync() {
[myfaces-tobago] 04/04: fix(selectOne|ManyList): Support for ajax onchange apache header
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bommel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit 4d293be4fb922945db05e3915740023d2dc851df
Author: Bernd Bohmann <bo...@apache.org>
AuthorDate: Thu May 11 12:40:59 2023 +0200
fix(selectOne|ManyList): Support for ajax onchange
apache header
issue: TOBAGO-2217
---
.../renderer/selectManyList/selectManyListAjax.html | 17 +++++++++++++++++
.../030-select/45-selectOneList/SelectOneList.xhtml | 1 -
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/tobago-core/src/test/resources/renderer/selectManyList/selectManyListAjax.html b/tobago-core/src/test/resources/renderer/selectManyList/selectManyListAjax.html
index 5eb4f78f72..a68d057a0c 100644
--- a/tobago-core/src/test/resources/renderer/selectManyList/selectManyListAjax.html
+++ b/tobago-core/src/test/resources/renderer/selectManyList/selectManyListAjax.html
@@ -1,3 +1,20 @@
+<!--
+ * 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.
+-->
+
<tobago-select-many-list id='id' class='tobago-auto-spacing'>
<select id='id::selected' name='id' class='d-none' multiple='multiple'>
<option value='Stratocaster'>Stratocaster
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/45-selectOneList/SelectOneList.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/45-selectOneList/SelectOneList.xhtml
index 1223c15bd3..4ea9a2cfc2 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/45-selectOneList/SelectOneList.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/45-selectOneList/SelectOneList.xhtml
@@ -90,7 +90,6 @@
<tc:selectOneList id="selectedExpanded" expanded="true">
<tc:selectItems value="#{selectOneListController.planets}"
var="planet" itemLabel="#{planet.name}" itemValue="#{planet}"/>
- <f:ajax render="@this" />
</tc:selectOneList>
</tc:section>
</ui:composition>
[myfaces-tobago] 03/04: fix(selectOne|ManyList): Support for ajax onchange apache header
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bommel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit 06b47ba84c9fee1fad274daa8fd861fd86288291
Author: Bernd Bohmann <bo...@apache.org>
AuthorDate: Thu May 11 12:39:23 2023 +0200
fix(selectOne|ManyList): Support for ajax onchange
apache header
issue: TOBAGO-2217
---
.../renderer/SelectManyListRendererUnitTest.java | 19 +++++++++++++++++++
.../renderer/SelectOneListRendererUnitTest.java | 19 +++++++++++++++++++
.../renderer/selectOneList/selectOneListAjax.html | 17 +++++++++++++++++
.../030-select/45-selectOneList/SelectOneList.xhtml | 1 +
4 files changed, 56 insertions(+)
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRendererUnitTest.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRendererUnitTest.java
index 3e1b3d8cc6..e9e5c9e42b 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRendererUnitTest.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyListRendererUnitTest.java
@@ -1,3 +1,22 @@
+/*
+ * 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.renderkit.renderer;
import jakarta.faces.component.behavior.AjaxBehavior;
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneListRendererUnitTest.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneListRendererUnitTest.java
index be516ba2f8..8059e8fc51 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneListRendererUnitTest.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneListRendererUnitTest.java
@@ -1,3 +1,22 @@
+/*
+ * 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.renderkit.renderer;
import jakarta.faces.component.behavior.AjaxBehavior;
diff --git a/tobago-core/src/test/resources/renderer/selectOneList/selectOneListAjax.html b/tobago-core/src/test/resources/renderer/selectOneList/selectOneListAjax.html
index 44abf9d2b5..79ebbf73f7 100644
--- a/tobago-core/src/test/resources/renderer/selectOneList/selectOneListAjax.html
+++ b/tobago-core/src/test/resources/renderer/selectOneList/selectOneListAjax.html
@@ -1,3 +1,20 @@
+<!--
+ * 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.
+-->
+
<tobago-select-one-list id='id' class='tobago-auto-spacing'>
<select id='id::selected' name='id' class='d-none'>
<option value='Stratocaster'>Stratocaster
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/45-selectOneList/SelectOneList.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/45-selectOneList/SelectOneList.xhtml
index 4ea9a2cfc2..1223c15bd3 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/45-selectOneList/SelectOneList.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/45-selectOneList/SelectOneList.xhtml
@@ -90,6 +90,7 @@
<tc:selectOneList id="selectedExpanded" expanded="true">
<tc:selectItems value="#{selectOneListController.planets}"
var="planet" itemLabel="#{planet.name}" itemValue="#{planet}"/>
+ <f:ajax render="@this" />
</tc:selectOneList>
</tc:section>
</ui:composition>