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

solomax pushed a commit to branch wicket-8.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-8.x by this push:
     new c76cf16ed8 [WICKET-6988] String.format is replaced with concatenation 
of strings
c76cf16ed8 is described below

commit c76cf16ed87ce469df36e95e8430a19dd55410e3
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Wed Jun 8 17:53:06 2022 +0700

    [WICKET-6988] String.format is replaced with concatenation of strings
---
 .../wicket/ajax/AbstractAjaxTimerBehavior.java     |  3 +-
 .../apache/wicket/ajax/AjaxTimerBehaviorTest.java  | 47 +++++++++++++++++++++-
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
index da947eefc1..e2e7eeeb00 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
@@ -201,8 +201,7 @@ public abstract class AbstractAjaxTimerBehavior extends 
AbstractDefaultAjaxBehav
                timerId = getTimerId();
 
                headerResponse.render(
-                       
OnLoadHeaderItem.forScript(String.format("Wicket.Timer.set('%s', 
function(){%s}, %d);",
-                               timerId, js, 
updateInterval.getMilliseconds())));
+                       OnLoadHeaderItem.forScript("Wicket.Timer.set('" + 
timerId + "', function(){" + js + "}, " + updateInterval.getMilliseconds() + 
");"));
        }
 
        private void clearTimeout(IHeaderResponse headerResponse)
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxTimerBehaviorTest.java 
b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxTimerBehaviorTest.java
index d8c2392326..3612757798 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxTimerBehaviorTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxTimerBehaviorTest.java
@@ -27,6 +27,8 @@ import org.apache.wicket.model.Model;
 import org.apache.wicket.util.tester.WicketTestCase;
 import org.apache.wicket.util.time.Duration;
 import org.junit.Test;
+import java.util.Locale;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,7 +84,6 @@ public class AjaxTimerBehaviorTest extends WicketTestCase
                assertMatches("Wicket.Timer.set", 1);
        }
 
-
        /**
         * tests timer behavior in a WebPage.
         */
@@ -204,6 +205,7 @@ public class AjaxTimerBehaviorTest extends WicketTestCase
        {
                final AbstractAjaxTimerBehavior timer = new 
AbstractAjaxTimerBehavior(Duration.seconds(20))
                {
+                       private static final long serialVersionUID = 1L;
                        private boolean enabled = true;
                        
                        @Override
@@ -331,6 +333,49 @@ public class AjaxTimerBehaviorTest extends WicketTestCase
                tester.assertLabel(labelPath, String.valueOf(labelInitialValue 
+ 2));
        }
 
+       /**
+        * Tests timer behavior in a component added to an AjaxRequestTarget
+        */
+       @Test
+       public void arabicAddedInAjaxSetsTimout()
+       {
+               Locale def = Locale.getDefault();
+               try {
+                       Locale.setDefault(Locale.forLanguageTag("ar-EG"));
+                       Duration dur = Duration.seconds(20);
+                       final AjaxSelfUpdatingTimerBehavior timer = new 
AjaxSelfUpdatingTimerBehavior(dur);
+                       final MockPageWithLinkAndComponent page = new 
MockPageWithLinkAndComponent();
+
+                       page.add(new 
WebComponent(MockPageWithLinkAndComponent.COMPONENT_ID)
+                               .setOutputMarkupId(true));
+
+
+                       page.add(new 
AjaxLink<Void>(MockPageWithLinkAndComponent.LINK_ID)
+                       {
+                               private static final long serialVersionUID = 1L;
+
+                               @Override
+                               public void onClick(AjaxRequestTarget target)
+                               {
+                                       WebMarkupContainer wmc = new 
WebMarkupContainer(
+                                               
MockPageWithLinkAndComponent.COMPONENT_ID);
+                                       wmc.setOutputMarkupId(true);
+                                       wmc.add(timer);
+                                       page.replace(wmc);
+                                       target.add(wmc);
+                               }
+                       });
+
+                       tester.startPage(page);
+                       tester.clickLink(MockPageWithLinkAndComponent.LINK_ID);
+
+                       // first render sets timeout in correct Locale
+                       assertMatches(", 20000", 1);
+               } finally {
+                       Locale.setDefault(def);
+               }
+       }
+
        /**
         * Validates the response, then makes sure the timer injects itself 
again when called.
         * 

Reply via email to