Skip to content

Commit 173f853

Browse files
committed
Fixes #1437: containerCssClass is replaced with selectionCssClass; select2 is retrieved via webjars
1 parent 5c6326b commit 173f853

79 files changed

Lines changed: 143 additions & 13595 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@
383383
<jquery-ui.version>1.14.2</jquery-ui.version>
384384
<moment-js.version>2.30.1</moment-js.version>
385385
<fullcalendar.version>6.1.15</fullcalendar.version>
386+
<select2.version>4.1.0-rc.0</select2.version>
386387
<owasp-sanitizer.version>20260313.1</owasp-sanitizer.version>
387388
<!-- plugins -->
388389
<maven-surefire-plugin.version>3.5.5</maven-surefire-plugin.version>
@@ -1055,6 +1056,11 @@
10551056
<artifactId>fullcalendar__google-calendar</artifactId>
10561057
<version>${fullcalendar.version}</version>
10571058
</dependency>
1059+
<dependency>
1060+
<groupId>org.webjars.npm</groupId>
1061+
<artifactId>select2</artifactId>
1062+
<version>${select2.version}</version>
1063+
</dependency>
10581064
<dependency>
10591065
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
10601066
<artifactId>owasp-java-html-sanitizer</artifactId>

select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import org.apache.wicket.markup.html.basic.Label;
2727
import org.apache.wicket.markup.html.form.ChoiceRenderer;
2828
import org.apache.wicket.markup.html.form.DropDownChoice;
29+
import org.apache.wicket.markup.html.form.EnumChoiceRenderer;
2930
import org.apache.wicket.markup.html.form.Form;
31+
import org.apache.wicket.markup.html.form.LambdaChoiceRenderer;
3032
import org.apache.wicket.markup.html.form.ListMultipleChoice;
3133
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
3234
import org.apache.wicket.model.PropertyModel;
@@ -50,17 +52,17 @@ public class HomePage extends WebPage
5052
@SuppressWarnings("unused")
5153
private Country countryDropDownChoice = Country.US;
5254
@SuppressWarnings("unused")
53-
private List<Country> countries = new ArrayList<>(Arrays.asList(new Country[] { Country.US, Country.CA }));
55+
private List<Country> countries = new ArrayList<>(List.of(Country.US, Country.CA));
5456
@SuppressWarnings("unused")
55-
private List<Country> ajaxcountries = new ArrayList<>(Arrays.asList(new Country[] { Country.US, Country.CA }));
57+
private List<Country> ajaxcountries = new ArrayList<>(List.of(Country.US, Country.CA));
5658
@SuppressWarnings("unused")
57-
private List<Country> ajaxcountriesns = new ArrayList<>(Arrays.asList(new Country[] { Country.US, Country.CA }));
59+
private List<Country> ajaxcountriesns = new ArrayList<>(List.of(Country.US, Country.CA));
5860
@SuppressWarnings("unused")
59-
private List<Country> countriesListMultipleChoice = new ArrayList<>(Arrays.asList(new Country[] { Country.US, Country.CA }));
61+
private List<Country> countriesListMultipleChoice = new ArrayList<>(List.of(Country.US, Country.CA));
6062
@SuppressWarnings("unused")
6163
private List<String> tags = new ArrayList<>(Arrays.asList("tag1", "tag2"));
6264
@SuppressWarnings("unused")
63-
private List<Country> countriesStateless = new ArrayList<>(Arrays.asList(new Country[] { Country.US, Country.CA }));
65+
private List<Country> countriesStateless = new ArrayList<>(List.of(Country.US, Country.CA));
6466

6567
@Override
6668
protected void onInitialize() {
@@ -337,15 +339,12 @@ public void query(String term, int page, Response<String> response)
337339
}
338340
}
339341

340-
public static class CountryRenderer extends ChoiceRenderer<Country>
342+
public static class CountryRenderer extends LambdaChoiceRenderer<Country>
341343
{
342-
343344
private static final long serialVersionUID = 1L;
344345

345346
public CountryRenderer() {
346-
super("displayName", "name");
347+
super(Country::getDisplayName, Country::name);
347348
}
348-
349349
}
350-
351350
}

select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/WicketApplication.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import org.apache.wicket.protocol.http.WebApplication;
1616

17+
import de.agilecoders.wicket.webjars.WicketWebjars;
18+
1719
/**
1820
* Application object
1921
*/
@@ -25,6 +27,7 @@ public class WicketApplication extends WebApplication
2527
protected void init() {
2628
getCspSettings().blocking().disabled();
2729
super.init();
30+
WicketWebjars.install(this);
2831

2932
mountPage("bootstrap", HomeBootstrapPage.class);
3033

select2-parent/select2/pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,21 @@
3535
</license>
3636
</licenses>
3737
<dependencies>
38+
<!-- webjars for bootstrap theme -->
39+
<dependency>
40+
<groupId>de.agilecoders.wicket.webjars</groupId>
41+
<artifactId>wicket-webjars</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.webjars.npm</groupId>
45+
<artifactId>select2</artifactId>
46+
</dependency>
3847
<dependency>
3948
<groupId>jakarta.servlet</groupId>
4049
<artifactId>jakarta.servlet-api</artifactId>
4150
<scope>provided</scope>
4251
</dependency>
52+
<!-- tests -->
4353
<dependency>
4454
<groupId>org.apache.wicket</groupId>
4555
<artifactId>wicket-tester</artifactId>
@@ -61,11 +71,6 @@
6171
<groupId>org.hamcrest</groupId>
6272
<artifactId>hamcrest-library</artifactId>
6373
</dependency>
64-
<!-- webjars for bootstrap theme -->
65-
<dependency>
66-
<groupId>de.agilecoders.wicket.webjars</groupId>
67-
<artifactId>wicket-webjars</artifactId>
68-
</dependency>
6974
</dependencies>
7075
<build>
7176
<resources>

select2-parent/select2/src/main/java/org/wicketstuff/select2/ApplicationSettings.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
22
* Copyright 2012 Igor Vaynberg
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with
55
* the License. You may obtain a copy of the License in the LICENSE file, or at:
6-
*
6+
*
77
* http://www.apache.org/licenses/LICENSE-2.0
8-
*
8+
*
99
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
1010
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
1111
* specific language governing permissions and limitations under the License.
@@ -15,32 +15,29 @@
1515
import org.apache.wicket.Application;
1616
import org.apache.wicket.MetaDataKey;
1717
import org.apache.wicket.protocol.http.WebApplication;
18-
import org.apache.wicket.request.resource.CssResourceReference;
19-
import org.apache.wicket.request.resource.JavaScriptResourceReference;
2018
import org.apache.wicket.request.resource.ResourceReference;
2119

20+
import de.agilecoders.wicket.webjars.request.resource.WebjarsCssResourceReference;
21+
import de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference;
22+
2223
/**
2324
* Application-wide settings that apply to all Select2 components.
24-
*
25+
*
2526
* The settings object is retreived via the static {@link #get()} method and is usually configured
2627
* in the {@link WebApplication#init()} method.
27-
*
28+
*
2829
* @author igor
2930
*/
3031
public class ApplicationSettings
3132
{
32-
3333
private static final MetaDataKey<ApplicationSettings> KEY = new MetaDataKey<ApplicationSettings>()
3434
{
3535
private static final long serialVersionUID = 1L;
3636
};
3737

38-
private ResourceReference javaScriptReference = new JavaScriptResourceReference(
39-
ApplicationSettings.class, "res/js/select2.js");
40-
private ResourceReference javaScriptReferenceFull = new JavaScriptResourceReference(
41-
ApplicationSettings.class, "res/js/select2.full.js");
42-
private ResourceReference cssReference = new CssResourceReference(
43-
ApplicationSettings.class, "res/css/select2.css");
38+
private ResourceReference javaScriptReference = new WebjarsJavaScriptResourceReference("select2/current/dist/js/select2.js");
39+
private ResourceReference javaScriptReferenceFull = new WebjarsJavaScriptResourceReference("select2/current/dist/js/select2.full.js");
40+
private ResourceReference cssReference = new WebjarsCssResourceReference("select2/current/dist/css/select2.css");
4441

4542
private boolean includeJavascriptFull = true;
4643
private boolean includeJavascript = false;
@@ -127,7 +124,7 @@ public ApplicationSettings setJavascriptReferenceFull(ResourceReference javaScri
127124

128125
/**
129126
* Retrieves the instance of settings object.
130-
*
127+
*
131128
* @return settings instance
132129
*/
133130
public static ApplicationSettings get()

select2-parent/select2/src/main/java/org/wicketstuff/select2/Settings.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static class Widths
6464
private String initSelection; //TODO Deprecated in Select2 4.0, will be removed in 4.1
6565
private String query; //TODO Deprecated in Select2 4.0, will be removed in 4.1
6666
private String width;
67-
private String containerCss, dropdownCss, containerCssClass, dropdownCssClass; //TODO deprecated
67+
private String containerCss, dropdownCss, selectionCssClass, dropdownCssClass; //TODO deprecated
6868
private String dropdownParent;
6969

7070
private AjaxSettings ajax;
@@ -121,7 +121,7 @@ public CharSequence toJson()
121121
Json.writeObject(writer, "width", width);
122122
Json.writeObject(writer, "theme", theme != null ? theme.name() : null);
123123
Json.writeFunction(writer, "containerCss", containerCss);
124-
Json.writeObject(writer, "containerCssClass", containerCssClass);
124+
Json.writeObject(writer, "selectionCssClass", selectionCssClass);
125125
Json.writeFunction(writer, "dropdownCss", dropdownCss);
126126
Json.writeObject(writer, "dropdownCssClass", dropdownCssClass);
127127
Json.writeObject(writer, "separator", separator);
@@ -451,14 +451,27 @@ public Settings setDropdownCss(String dropdownCss)
451451
return this;
452452
}
453453

454+
@Deprecated(forRemoval = true, since = "10.9")
454455
public String getContainerCssClass()
455456
{
456-
return containerCssClass;
457+
return selectionCssClass;
457458
}
458459

459-
public Settings setContainerCssClass(String containerCssClass)
460+
@Deprecated(forRemoval = true, since = "10.9")
461+
public Settings setContainerCssClass(String selectionCssClass)
460462
{
461-
this.containerCssClass = containerCssClass;
463+
this.selectionCssClass = selectionCssClass;
464+
return this;
465+
}
466+
467+
public String getSelectionCssClass()
468+
{
469+
return selectionCssClass;
470+
}
471+
472+
public Settings setSelectionCssClass(String containerCssClass)
473+
{
474+
this.selectionCssClass = containerCssClass;
462475
return this;
463476
}
464477

0 commit comments

Comments
 (0)