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 2025/09/23 15:11:03 UTC

(myfaces-tobago) branch main updated: bug(demo): example of the ui:repeat id issue (#6737)

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

lofwyr 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 ad4708c70d bug(demo): example of the ui:repeat id issue (#6737)
ad4708c70d is described below

commit ad4708c70d2e6113ef0db741a8fa93241359ee0e
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Tue Sep 23 17:10:58 2025 +0200

    bug(demo): example of the ui:repeat id issue (#6737)
    
    issue: TOBAGO-2440
---
 .../tobago/example/demo/test/RepeatController.java | 14 +++++
 .../content/900-test/9020-ui-repeat/Repeat.xhtml   |  2 +-
 .../content/900-test/9020-ui-repeat/Toolbar.xhtml  | 66 ++++++++++++++++++++++
 3 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/RepeatController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/RepeatController.java
index fe992b84fa..e0dde28755 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/RepeatController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/RepeatController.java
@@ -27,6 +27,7 @@
 import java.io.Serializable;
 import java.lang.invoke.MethodHandles;
 import java.util.List;
+import java.util.Locale;
 
 @SessionScoped
 @Named
@@ -36,6 +37,7 @@ public class RepeatController implements Serializable {
 
   private final List<String> list = List.of("A", "B", "C");
   private int counter = 0;
+  private Locale locale;
 
   public List<String> getList() {
     return list;
@@ -53,4 +55,16 @@ public void action() {
     counter++;
     LOG.info("Action on RepeatController. Counter now: " + counter);
   }
+
+  public List<Locale> getAllLocales() {
+    return List.of(Locale.US, Locale.GERMANY, Locale.JAPAN);
+  }
+
+  public Locale getLocale() {
+    return locale;
+  }
+
+  public void setLocale(Locale locale) {
+    this.locale = locale;
+  }
 }
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/9020-ui-repeat/Repeat.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/9020-ui-repeat/Repeat.xhtml
index b007d3f640..6d764d30ec 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/9020-ui-repeat/Repeat.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/9020-ui-repeat/Repeat.xhtml
@@ -19,7 +19,7 @@
 <ui:composition template="/main.xhtml"
                 xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
-                xmlns:ui="http://java.sun.com/jsf/facelets">
+                xmlns:ui="jakarta.faces.facelets">
 
   <tc:section label="Test of &lt;ui:repeat>">
 
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/9020-ui-repeat/Toolbar.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/9020-ui-repeat/Toolbar.xhtml
new file mode 100644
index 0000000000..5b4d7c8277
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/9020-ui-repeat/Toolbar.xhtml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+
+<ui:composition template="/main.xhtml"
+                xmlns="http://www.w3.org/1999/xhtml"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:ui="jakarta.faces.facelets"
+                xmlns:f="jakarta.faces.core">
+
+  <tc:box label="Test repeat in the tool bar.">
+    <f:facet name="bar">
+      <tc:bar>
+        <!-- with form -->
+        <tc:form>
+          <tc:link label="With Form" image="fa-language" omit="true">
+            <ui:repeat id="repeatLocale" value="#{repeatController.allLocales}" var="locale">
+              <tc:link id="linkLocale"
+                       image="#{repeatController.locale == locale ? 'fa-check' : ''}"
+                       label="#{locale.getDisplayName()} in loop (reloadLocale)"
+                       action="#{repeatController.setLocale(locale)}">
+                <tc:style marginLeft="24px" rendered="#{repeatController.locale != locale}"/>
+              </tc:link>
+            </ui:repeat>
+          </tc:link>
+        </tc:form>
+
+        <tc:out value="    "/>
+
+        <!-- without form -->
+        <tc:link label="Without Form" image="fa-language" omit="true">
+          <ui:repeat id="repeatLocaleTwo" value="#{repeatController.allLocales}" var="locale">
+            <tc:link id="linkLocaleTow"
+                     image="#{repeatController.locale == locale ? 'fa-check' : ''}"
+                     label="#{locale.getDisplayName()} in loop (reloadLocale)"
+                     action="#{repeatController.setLocale(locale)}">
+              <tc:style marginLeft="24px" rendered="#{repeatController.locale != locale}"/>
+            </tc:link>
+          </ui:repeat>
+        </tc:link>
+      </tc:bar>
+    </f:facet>
+
+    <tc:out label="Locale:" value="#{repeatController.locale}"/>
+
+    <tc:in label="Required" required="true"/>
+
+    The version with form is broken, when the form has no id or the id contains digits!
+
+  </tc:box>
+
+</ui:composition>