This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch wicket-9.x
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/wicket-9.x by this push:
new f44712e2df [WICKET-6988] String.format is replaced with concatenation
of strings
f44712e2df is described below
commit f44712e2df92df315edf23c3b82b475f3f764c47
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 | 59 +++++++++++++++++++---
2 files changed, 53 insertions(+), 9 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 23d31fc967..78a8f78a04 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
@@ -211,8 +211,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.toMillis())));
+ OnLoadHeaderItem.forScript("Wicket.Timer.set('" +
timerId + "', function(){" + js + "}, " + updateInterval.toMillis() + ");"));
}
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 9a6a3d6bb6..fbd7c26f83 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
@@ -28,6 +28,8 @@ import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.tester.WicketTestCase;
import java.time.Duration;
+import java.util.Locale;
+
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +48,7 @@ class AjaxTimerBehaviorTest extends WicketTestCase
* Tests timer behavior in a component added to an AjaxRequestTarget
*/
@Test
- void addedInAjaxSetsTimout()
+ void addedInAjaxSetsTimout()
{
Duration dur = Duration.ofSeconds(20);
final AjaxSelfUpdatingTimerBehavior timer = new
AjaxSelfUpdatingTimerBehavior(dur);
@@ -83,12 +85,11 @@ class AjaxTimerBehaviorTest extends WicketTestCase
assertMatches("Wicket.Timer.set", 1);
}
-
/**
* tests timer behavior in a WebPage.
*/
@Test
- void pageRenderSetsTimeout()
+ void pageRenderSetsTimeout()
{
Duration dur = Duration.ofSeconds(20);
final AjaxSelfUpdatingTimerBehavior timer = new
AjaxSelfUpdatingTimerBehavior(dur);
@@ -125,7 +126,7 @@ class AjaxTimerBehaviorTest extends WicketTestCase
* tests timer behavior in a WebPage.
*/
@Test
- void ajaxUpdateDoesNotSetTimeout()
+ void ajaxUpdateDoesNotSetTimeout()
{
Duration dur = Duration.ofSeconds(20);
final AjaxSelfUpdatingTimerBehavior timer = new
AjaxSelfUpdatingTimerBehavior(dur);
@@ -162,7 +163,7 @@ class AjaxTimerBehaviorTest extends WicketTestCase
/**
*/
@Test
- void setVisibleSetsTimeout()
+ void setVisibleSetsTimeout()
{
Duration dur = Duration.ofSeconds(20);
final AjaxSelfUpdatingTimerBehavior timer = new
AjaxSelfUpdatingTimerBehavior(dur);
@@ -201,10 +202,11 @@ class AjaxTimerBehaviorTest extends WicketTestCase
/**
*/
@Test
- void setDisabledClearsTimeout()
+ void setDisabledClearsTimeout()
{
final AbstractAjaxTimerBehavior timer = new
AbstractAjaxTimerBehavior(Duration.ofSeconds(20))
{
+ private static final long serialVersionUID = 1L;
private boolean enabled = true;
@Override
@@ -251,7 +253,7 @@ class AjaxTimerBehaviorTest extends WicketTestCase
* WICKET-1525, WICKET-2152
*/
@Test
- void restartResultsInAddTimeout()
+ void restartResultsInAddTimeout()
{
final Integer labelInitialValue = Integer.valueOf(0);
@@ -332,6 +334,49 @@ class AjaxTimerBehaviorTest extends WicketTestCase
tester.assertLabel(labelPath, String.valueOf(labelInitialValue
+ 2));
}
+ /**
+ * Tests timer behavior in a component added to an AjaxRequestTarget
+ */
+ @Test
+ void arabicAddedInAjaxSetsTimout()
+ {
+ Locale def = Locale.getDefault();
+ try {
+ Locale.setDefault(Locale.forLanguageTag("ar-EG"));
+ Duration dur = Duration.ofSeconds(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.
*