diff --git a/jdk-1.7-parent/select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.html b/jdk-1.7-parent/select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.html index 553d1c2b65..73bd96f7e6 100755 --- a/jdk-1.7-parent/select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.html +++ b/jdk-1.7-parent/select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.html @@ -43,28 +43,6 @@

Single-Select Ajax result loading. Paging with infinite scrolling. Mi - -
- -
-
-

- Country currently selected: -

-
- -
- -
-
-
-
-
-
-
- -
-
-

- Countries currently selected: -

-
- -
- -
-
-
-
-
diff --git a/jdk-1.7-parent/select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.java b/jdk-1.7-parent/select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.java index df4a423490..d4c3ab9481 100755 --- a/jdk-1.7-parent/select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.java +++ b/jdk-1.7-parent/select2-parent/select2-examples/src/main/java/org/wicketstuff/select2/HomePage.java @@ -19,7 +19,6 @@ import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.ChoiceRenderer; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.PropertyModel; @@ -37,14 +36,12 @@ public class HomePage extends WebPage @SuppressWarnings("unused") private Country country = Country.US; @SuppressWarnings("unused") - private List countries = new ArrayList<>(Arrays.asList(new Country[] { Country.US, - Country.CA })); + private List countries = new ArrayList<>(Arrays.asList( + new Country[] { Country.US, Country.CA })); public HomePage() { - // single-select example - add(new Label("country", new PropertyModel<>(this, "country"))); Form form = new Form("single"); @@ -55,18 +52,7 @@ public HomePage() country.getSettings().setMinimumInputLength(1); form.add(country); - add(new Label("country-non-ajax", new PropertyModel<>(this, "country"))); - - Form nonAjaxform = new Form("single-non-ajax"); - add(nonAjaxform); - Select2Choice nonAjaxCountry = new Select2Choice<>("country-non-ajax", - new PropertyModel(this, "country"), Arrays.asList(Country.values()), - new CountriesRenderer()); - nonAjaxCountry.getSettings().setMinimumInputLength(1); - nonAjaxform.add(nonAjaxCountry); - // multi-select example - add(new Label("countries", new PropertyModel<>(this, "countries"))); Form multi = new Form("multi"); @@ -77,17 +63,6 @@ public HomePage() countries.getSettings().setMinimumInputLength(1); countries.add(new DragAndDropBehavior()); multi.add(countries); - - add(new Label("countries-non-ajax", new PropertyModel<>(this, "countries"))); - Form nonAjaxMulti = new Form("multi-non-ajax"); - add(nonAjaxMulti); - - countries = new Select2MultiChoice<>("countries-non-ajax", - new PropertyModel>(this, "countries"), - Arrays.asList(Country.values()), new CountriesRenderer()); - countries.getSettings().setMinimumInputLength(1); - countries.add(new DragAndDropBehavior()); - nonAjaxMulti.add(countries); } /** @@ -105,11 +80,8 @@ public HomePage() */ private static List queryMatches(String term, int page, int pageSize) { - List result = new ArrayList<>(); - term = term.toUpperCase(); - final int offset = page * pageSize; int matched = 0; @@ -175,12 +147,4 @@ public Collection toChoices(Collection ids) } } - private static class CountriesRenderer extends ChoiceRenderer - { - - public CountriesRenderer() - { - super("displayName"); - } - } } diff --git a/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/AbstractSelect2Choice.java b/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/AbstractSelect2Choice.java index c4ed3bba32..c875086acb 100755 --- a/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/AbstractSelect2Choice.java +++ b/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/AbstractSelect2Choice.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.OutputStreamWriter; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -28,15 +27,12 @@ import org.apache.wicket.markup.head.OnDomReadyHeaderItem; import org.apache.wicket.markup.html.form.FormComponent; import org.apache.wicket.markup.html.form.HiddenField; -import org.apache.wicket.markup.html.form.IChoiceRenderer; import org.apache.wicket.model.IModel; -import org.apache.wicket.model.util.ListModel; import org.apache.wicket.request.IRequestParameters; import org.apache.wicket.request.Request; import org.apache.wicket.request.http.WebRequest; import org.apache.wicket.request.http.WebResponse; import org.apache.wicket.util.string.Strings; -import org.wicketstuff.select2.json.JsonBuilder; /** * Base class for Select2 components @@ -46,11 +42,6 @@ * @param * type of model object * @author igor - * - * @param - * type of choice object - * @param - * type of model object */ abstract class AbstractSelect2Choice extends HiddenField implements IResourceListener { @@ -60,20 +51,17 @@ abstract class AbstractSelect2Choice extends HiddenField implements IRe private final Settings settings = new Settings(); private ChoiceProvider provider; - private List choices; - private IChoiceRenderer renderer; private boolean convertInputPerformed = false; + /** - * Constructor - * * @param id - * component id + * markup id */ public AbstractSelect2Choice(String id) { - this(id, null, null, null); + this(id, null, null); } /** @@ -86,9 +74,10 @@ public AbstractSelect2Choice(String id) */ public AbstractSelect2Choice(String id, IModel model) { - this(id, model, null, null); + this(id, model, null); } + /** * Constructor. * @@ -102,24 +91,6 @@ public AbstractSelect2Choice(String id, ChoiceProvider provider) this(id, null, provider); } - /** - * Constructor - * - * @param id - * component id - * @param model - * component model - * @param provider - * choice provider - */ - public AbstractSelect2Choice(String id, IModel model, ChoiceProvider provider) - { - super(id, model); - this.provider = provider; - add(new Select2ResourcesBehavior()); - setOutputMarkupId(true); - } - /** * Construct. * @@ -127,56 +98,14 @@ public AbstractSelect2Choice(String id, IModel model, ChoiceProvider provi * markup id * @param model * model for select - * @param collection - * list options for select - */ - public AbstractSelect2Choice(String id, IModel model, List collection) - { - this(id, model, collection, null); - } - - /** - * @param id - * markup id - * @param choices - * list options for select - * @param renderer - * list item renderer - */ - public AbstractSelect2Choice(String id, List choices, IChoiceRenderer renderer) - { - this(id, null, choices, renderer); - } - - /** - * Construct. * - * @param id - * markup id - * @param model - * model for select - * @param choices - * list options for select - * @param renderer - * renderer list item * @see HiddenField#HiddenField(String, IModel) */ - public AbstractSelect2Choice(String id, IModel model, List choices, IChoiceRenderer renderer) + public AbstractSelect2Choice(String id, IModel model, ChoiceProvider provider) { super(id, model); - if (null == choices) - { - throw new IllegalStateException("Select2 choice component: " + getId() + - " does not have a List set"); - } - if (null == renderer) - { - throw new IllegalStateException("Select2 choice component: " + getId() + - " does not have a WCLChoiceRenderer set"); - } + this.provider = provider; add(new Select2ResourcesBehavior()); - this.choices = new ArrayList<>(choices); - this.renderer = renderer; setOutputMarkupId(true); } @@ -199,39 +128,6 @@ public final void setProvider(ChoiceProvider provider) this.provider = provider; } - /** - * @return data - */ - public final List getChoices() - { - if (choices == null) - { - throw new IllegalStateException("Select2 choice component: " + getId() + - " does not have a choices set"); - } - return choices; - } - - public final void setChoices(List choices) - { - this.choices = choices; - } - - public final IChoiceRenderer getRenderer() - { - if (renderer == null) - { - throw new IllegalStateException("Select2 choice component: " + getId() + - " does not have a IChoiceRenderer set"); - } - return renderer; - } - - public final void setRenderer(IChoiceRenderer renderer) - { - this.renderer = renderer; - } - /** * @return choice provider */ @@ -254,30 +150,20 @@ public final void convertInput() convertInputPerformed = true; } + /** + * Convert IDS into choices. + * + * @param ids + * list of identities + * @return collection of choices or empty collection + */ protected final Collection convertIdsToChoices(List ids) { if (ids == null || ids.isEmpty()) { return Collections.emptyList(); } - if (isAjax()) - { - return getProvider().toChoices(ids); - } - else - { - ListModel model = new ListModel<>(getChoices()); - List result = new ArrayList<>(ids.size()); - for (String id : ids) - { - T choice = getRenderer().getObject(id, model); - if (choice != null) - { - result.add(choice); - } - } - return result; - } + return getProvider().toChoices(ids); } /** @@ -310,11 +196,7 @@ protected String getEscapedJsString(String key) public void renderHead(IHeaderResponse response) { super.renderHead(response); - if (!isAjax()) - { - // attach select options - renderChoices(); - } + // initialize select2 response.render(OnDomReadyHeaderItem.forScript(JQuery.execute("$('#%s').select2(%s);", getJquerySafeMarkupId(), getSettings().toJson()))); @@ -390,7 +272,7 @@ protected void onInitialize() getSettings().setFormatLoadMore( "function() { return '" + getEscapedJsString("loadMore") + "';}"); getSettings().setFormatSearching( - "function() { return '" + getEscapedJsString("searching") + "';}"); + "function() { return '" + getEscapedJsString("searching") + "';}"); } @Override @@ -452,7 +334,7 @@ public void onResourceRequested() // 0-based page -= 1; - Response response = new Response(); + Response response = new Response<>(); getProvider().query(term, page, response); // jsonize and write out the choices to the response @@ -503,60 +385,15 @@ protected void onDetach() super.onDetach(); } - /** - * render single choice - * - * @param choice - * choice - * @param jsonBuilder - * json builder - */ - protected void renderChoice(T choice, JsonBuilder jsonBuilder) - { - String key = getRenderer().getIdValue(choice, getChoices().lastIndexOf(choice)); - Object value = getRenderer().getDisplayValue(choice); - jsonBuilder.key("id").value(key).key("text").value(value); - } - - // render options on select2 - private void renderChoices() - { - JsonBuilder selection = new JsonBuilder(); - try - { - selection.object(); - selection.key("more").value(false); - selection.key("results").array(); - attachChoicesJson(selection); - selection.endArray().endObject(); - } - catch (JSONException e) - { - throw new RuntimeException("Error converting model object to Json", e); - } - - getSettings().setData(selection.toJson().toString()); - } - - private void attachChoicesJson(JsonBuilder jsonBuilder) throws JSONException - { - for (T choice : getChoices()) - { - jsonBuilder.object(); - renderChoice(choice, jsonBuilder); - jsonBuilder.endObject(); - } - } - private static boolean canInitializeInitialValue(Object value) { - if (value instanceof Collection) - { - return !((Collection) value).isEmpty(); - }else - { - return value != null; - } - } + if (value instanceof Collection) + { + return !((Collection) value).isEmpty(); + } else + { + return value != null; + } + } } diff --git a/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Response.java b/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Response.java index 621e8fee92..f78ab731a7 100755 --- a/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Response.java +++ b/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Response.java @@ -27,7 +27,7 @@ */ public class Response implements Iterable { - private List results = new ArrayList(); + private List results = new ArrayList<>(); private Boolean hasMore; public Response() diff --git a/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Select2Choice.java b/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Select2Choice.java index fb2d2f9aaf..5eece1b2ed 100755 --- a/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Select2Choice.java +++ b/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Select2Choice.java @@ -14,13 +14,10 @@ import java.util.Collections; import java.util.Iterator; -import java.util.List; import org.apache.wicket.ajax.json.JSONException; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.OnDomReadyHeaderItem; -import org.apache.wicket.markup.html.form.IChoiceRenderer; -import org.apache.wicket.markup.html.form.ChoiceRenderer; import org.apache.wicket.model.IModel; import org.apache.wicket.util.convert.ConversionException; import org.apache.wicket.util.string.Strings; @@ -38,34 +35,48 @@ public class Select2Choice extends AbstractSelect2Choice private static final long serialVersionUID = 1L; - public Select2Choice(String id, IModel model, List choices, ChoiceRenderer renderer) - { - super(id, model, choices, renderer); - } - - public Select2Choice(String id, IModel model, ChoiceProvider provider) - { - super(id, model, provider); - } - - public Select2Choice(String id, IModel model, List choices, IChoiceRenderer renderer) + /** + * Constructor. + * + * @param id + */ + public Select2Choice(String id) { - super(id, model, choices, renderer); + super(id); } - public Select2Choice(String id, List choices, IChoiceRenderer renderer) + /** + * Constructor. + * + * @param id + * @param model + */ + public Select2Choice(String id, IModel model) { - super(id, choices, renderer); + super(id, model); } - public Select2Choice(String id, IModel model) + /** + * Constructor. + * + * @param id + * @param model + * @param provider + */ + public Select2Choice(String id, IModel model, ChoiceProvider provider) { - super(id, model); + super(id, model, provider); } - public Select2Choice(String id) + /** + * Constructor. + * + * @param id + * @param provider + */ + public Select2Choice(String id, ChoiceProvider provider) { - super(id); + super(id, provider); } @Override @@ -89,14 +100,7 @@ protected void renderInitializationScript(IHeaderResponse response, T choice) try { selection.object(); - if (isAjax()) - { - getProvider().toJson(choice, selection); - } - else - { - renderChoice(choice, selection); - } + getProvider().toJson(choice, selection); selection.endObject(); } catch (JSONException e) diff --git a/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Select2MultiChoice.java b/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Select2MultiChoice.java index 4dffb58b04..93721b1991 100755 --- a/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Select2MultiChoice.java +++ b/jdk-1.7-parent/select2-parent/select2/src/main/java/org/wicketstuff/select2/Select2MultiChoice.java @@ -14,14 +14,11 @@ import java.util.Arrays; import java.util.Collection; -import java.util.List; import org.apache.wicket.ajax.json.JSONException; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.OnDomReadyHeaderItem; -import org.apache.wicket.markup.html.form.ChoiceRenderer; import org.apache.wicket.markup.html.form.FormComponent; -import org.apache.wicket.markup.html.form.IChoiceRenderer; import org.apache.wicket.model.IModel; import org.apache.wicket.util.convert.ConversionException; import org.apache.wicket.util.string.Strings; @@ -40,39 +37,28 @@ public class Select2MultiChoice extends AbstractSelect2Choice> model, List choices, - ChoiceRenderer renderer) - { - super(id, model, choices, renderer); - } - private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final String EMPTY_STRING = ""; - public Select2MultiChoice(String id, IModel> model, ChoiceProvider provider) - { - super(id, model, provider); - } - - public Select2MultiChoice(String id, List choices, IChoiceRenderer renderer) + public Select2MultiChoice(String id) { - super(id, null, choices, renderer); + super(id); } - public Select2MultiChoice(String id, IModel> model, List choices, IChoiceRenderer renderer) + public Select2MultiChoice(String id, IModel> model) { - super(id, model, choices, renderer); + super(id, model); } - public Select2MultiChoice(String id, IModel> model) + public Select2MultiChoice(String id, IModel> model, ChoiceProvider provider) { - super(id, model); + super(id, model, provider); } - public Select2MultiChoice(String id) + public Select2MultiChoice(String id, ChoiceProvider provider) { - super(id); + super(id, provider); } @Override @@ -138,14 +124,7 @@ protected void renderInitializationScript(IHeaderResponse response, Collection toChoices(Collection ids) private static List countryMatches(String term, int page, int pageSize) { - List result = new ArrayList<>(PAGE_SIZE); + List result = new ArrayList<>(pageSize); int offset = page * pageSize; int matched = 0; for (Country country : Country.values()) diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/CountryChoiceRenderer.java b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/CountryChoiceRenderer.java deleted file mode 100644 index b78ffdb228..0000000000 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/CountryChoiceRenderer.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.wicketstuff.select2; - -import java.util.List; - -import org.apache.wicket.markup.html.form.IChoiceRenderer; -import org.apache.wicket.model.IModel; - -/** - * @author lexx - */ -public final class CountryChoiceRenderer implements IChoiceRenderer -{ - - @Override - public Object getDisplayValue(Country object) - { - return object == null ? "" : object.getDisplayName(); - } - - @Override - public String getIdValue(Country object, int index) - { - return object == null ? "" : object.name(); - } - - @Override - public Country getObject(String id, IModel> choices) - { - List countries = choices.getObject(); - for (int index = 0; index < countries.size(); index++) - { - Country country = countries.get(index); - if (getIdValue(country, index).equals(id)) - { - return country; - } - } - return null; - } - -} diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoicePage.java b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoicePage.java index ba9dfefe3f..a26296ca34 100644 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoicePage.java +++ b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoicePage.java @@ -21,14 +21,14 @@ public Select2ChoicePage() { super(); - this.city = new TextField("city", new Model()); + this.city = new TextField<>("city", new Model()); this.city.setRequired(true); - this.country = new Select2Choice("country", new Model(), + this.country = new Select2Choice<>("country", new Model(), new CountryChoiceProvider()); this.country.setRequired(true); - this.form = new Form("form"); + this.form = new Form<>("form"); this.form.add(this.country); this.form.add(this.city); add(this.form); diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererPage.html b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererPage.html deleted file mode 100644 index e56190b13a..0000000000 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererPage.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -
- -
- - \ No newline at end of file diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererPage.java b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererPage.java deleted file mode 100644 index ad72be94e4..0000000000 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererPage.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.wicketstuff.select2; - -import java.util.Arrays; - -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.model.Model; - -/** - * @author lexx - */ -public class Select2ChoiceRendererPage extends WebPage -{ - - final Select2Choice country; - - final Form form; - - public Select2ChoiceRendererPage() - { - super(); - this.country = new Select2Choice("country", new Model(), Arrays.asList(Country.values()), - new CountryChoiceRenderer()); - this.form = new Form("form"); - this.form.add(this.country); - add(this.form); - } - -} diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererTest.java b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererTest.java deleted file mode 100644 index 31023cb6fb..0000000000 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2ChoiceRendererTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.wicketstuff.select2; - -import junit.framework.TestCase; -import org.apache.wicket.util.tester.FormTester; -import org.apache.wicket.util.tester.WicketTester; -import org.junit.Assert; - -/** - * @author lexx - */ -public class Select2ChoiceRendererTest extends TestCase -{ - - public void testSelect2ChoiceRendererInitialization() throws Exception - { - WicketTester wicketTester = new WicketTester(); - - Select2ChoiceRendererPage page = new Select2ChoiceRendererPage(); - wicketTester.startPage(page); - wicketTester.assertRenderedPage(Select2ChoiceRendererPage.class); - Assert.assertTrue(wicketTester.getLastResponseAsString().contains(expectedClientSideJavaScriptInitialization())); - - FormTester formTester = wicketTester.newFormTester(page.form.getPageRelativePath()); - formTester.setValue(page.country, country().name()); - formTester.submit(); - - Assert.assertFalse(page.form.hasError()); - Assert.assertSame(country(), page.country.getModelObject()); - Assert.assertTrue(wicketTester.getLastResponseAsString().contains(expectedSelect2JavaScriptInitialization())); - - wicketTester.startPage(wicketTester.getLastRenderedPage()); // and refresh page again - Assert.assertSame(country(), page.country.getModelObject()); - Assert.assertTrue(wicketTester.getLastResponseAsString().contains(expectedSelect2JavaScriptInitialization())); - } - - private static Country country() - { - return Country.BR; - } - - private static String expectedClientSideJavaScriptInitialization() - { - return "\"data\":{\"more\":false,\"results\":[{\"id\":\"AF\",\"text\":\"Afghanistan\"}"; - } - - private static String expectedSelect2JavaScriptInitialization() - { - return ".select2('data', {\"id\":\"BR\",\"text\":\"Brazil\"});"; - } -} diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoicePage.java b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoicePage.java index 653ff564ef..14abcae880 100644 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoicePage.java +++ b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoicePage.java @@ -22,14 +22,14 @@ public Select2MultiChoicePage() { super(); - this.city = new TextField("city", new Model()); + this.city = new TextField<>("city", new Model()); this.city.setRequired(true); - this.country = new Select2MultiChoice("country", new CollectionModel(), + this.country = new Select2MultiChoice<>("country", new CollectionModel(), new CountryChoiceProvider()); this.country.setRequired(true); - this.form = new Form("form"); + this.form = new Form<>("form"); this.form.add(this.country); this.form.add(this.city); add(this.form); diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererPage.html b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererPage.html deleted file mode 100644 index 0d902f74bf..0000000000 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererPage.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -
- -
- - \ No newline at end of file diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererPage.java b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererPage.java deleted file mode 100644 index 9ac3aa4909..0000000000 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererPage.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.wicketstuff.select2; - -import java.util.Arrays; - -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.model.util.CollectionModel; - -/** - * @author lexx - */ -public class Select2MultiChoiceRendererPage extends WebPage -{ - - final Select2MultiChoice countries; - - final Form form; - - public Select2MultiChoiceRendererPage() - { - super(); - this.countries = new Select2MultiChoice("countries", new CollectionModel(), - Arrays.asList(Country.values()), new CountryChoiceRenderer()); - this.form = new Form("form"); - this.form.add(this.countries); - add(this.form); - } -} diff --git a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererTest.java b/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererTest.java deleted file mode 100644 index 569f859dd9..0000000000 --- a/jdk-1.7-parent/select2-parent/select2/src/test/java/org/wicketstuff/select2/Select2MultiChoiceRendererTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.wicketstuff.select2; - -import java.util.Arrays; -import java.util.Collection; - -import junit.framework.TestCase; -import org.apache.wicket.util.tester.FormTester; -import org.apache.wicket.util.tester.WicketTester; -import org.junit.Assert; - -/** - * @author lexx - */ -public class Select2MultiChoiceRendererTest extends TestCase -{ - - public void testSelect2MultiChoiceRendererInitialization() throws Exception - { - WicketTester wicketTester = new WicketTester(); - - Select2MultiChoiceRendererPage page = new Select2MultiChoiceRendererPage(); - wicketTester.startPage(page); - wicketTester.assertRenderedPage(Select2MultiChoiceRendererPage.class); - Assert.assertTrue(wicketTester.getLastResponseAsString().contains(expectedClientSideJavaScriptInitialization())); - - FormTester formTester = wicketTester.newFormTester(page.form.getPageRelativePath()); - formTester.setValue(page.countries, countriesAsRawInput()); - formTester.submit(); - - Assert.assertFalse(page.form.hasError()); - Assert.assertTrue(page.countries.getModelObject().containsAll(countries())); - Assert.assertTrue(wicketTester.getLastResponseAsString().contains(expectedSelect2JavaScriptInitialization())); - - wicketTester.startPage(wicketTester.getLastRenderedPage()); // and refresh page again - Assert.assertTrue(page.countries.getModelObject().containsAll(countries())); - Assert.assertTrue(wicketTester.getLastResponseAsString().contains(expectedSelect2JavaScriptInitialization())); - } - - private static String countriesAsRawInput() - { - return Country.AM.name() + "," + Country.MC.name(); - } - - private static Collection countries() - { - return Arrays.asList(Country.AM, Country.MC); - } - - private static String expectedClientSideJavaScriptInitialization() - { - return "\"data\":{\"more\":false,\"results\":[{\"id\":\"AF\",\"text\":\"Afghanistan\"}"; - } - - private static String expectedSelect2JavaScriptInitialization() - { - return ".select2('data', [{\"id\":\"AM\",\"text\":\"Armenia\"},{\"id\":\"MC\",\"text\":\"Monaco\"}]);"; - } -} diff --git a/jdk-1.7-parent/wicketstuff-restannotations-parent/readme.md b/jdk-1.7-parent/wicketstuff-restannotations-parent/readme.md index be954d2a09..f12bac5a34 100644 --- a/jdk-1.7-parent/wicketstuff-restannotations-parent/readme.md +++ b/jdk-1.7-parent/wicketstuff-restannotations-parent/readme.md @@ -68,7 +68,7 @@ public interface IObjectSerialDeserial{
The main module comes with class `TextualObjectSerialDeserial` which implements both `IWebSerialDeserial` and `IObjectSerialDeserial` and that can be used as base class to implement serials/deserials that work with a textual MIME type and that need to know which charset encoding should be used.
-As JSON is de-facto standard format for REST API, the project comes also a ready-to-use resources (`GsonRestResource`) and two serials/deserials (`GsonSerialDeserial`, `JacksonObjectSerialDeserial`) that work with JSON format (both inside module 'restannotations-json'). The `GsonRestResource` and `GsonSerialDeserial` use [Gson](http://code.google.com/p/google-gson/) as Json library while `JacksonObjectSerialDeserial` is based on [Jackson](http://jackson.codehaus.org/). Resource `PersonsRestResource` in the example module is based on `GsonRestResource`. +As JSON is de-facto standard format for REST API, the project comes also a ready-to-use resources (`GsonRestResource`) and two serials/deserials (`GsonSerialDeserial`, `JacksonObjectSerialDeserial`) that work with JSON format (both inside module 'restannotations-json'). The `GsonRestResource` and `GsonSerialDeserial` use [Gson](http://code.google.com/p/google-gson/) as Json library while `JacksonObjectSerialDeserial` is based on [Jackson]( https://github.com/FasterXML/jackson). Resource `PersonsRestResource` in the example module is based on `GsonRestResource`. Mounting resources to a specific path ---------