Skip to content

Commit

Permalink
Merge pull request #402 from tgoetz/master
Browse files Browse the repository at this point in the history
[select2] Revert non-ajax support
  • Loading branch information
martin-g committed May 8, 2015
2 parents b61e084 + e1b0039 commit 1fc93db
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 559 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,6 @@ <h1>Single-Select <small>Ajax result loading. Paging with infinite scrolling. Mi
</div>
</div>
</section>

<section>
<div class="page-header">
<h1>Single-Select <small>Non-ajax result loading.</small></h1>
</div>
<div class="row">
<div class="span12">
<p>
Country currently selected: <strong><span
wicket:id="country-non-ajax"></span> </strong>
</p>
<form wicket:id="single-non-ajax">
<input wicket:id="country-non-ajax" type="hidden"
style="width: 300px;" />
<div class="form-actions">
<button type="submit" class="btn">Submit</button>
</div>
</form>
</div>
</div>
</section>

<section>
<div class="page-header">
<h1>Multi-Select <small>Ajax result loading. Paging with infinite scrolling. Minimum input length. Drag &amp; Drop</small></h1>
Expand All @@ -85,26 +63,6 @@ <h1>Multi-Select <small>Ajax result loading. Paging with infinite scrolling. Min
</div>
</div>
</section>
<section>
<div class="page-header">
<h1>Multi-Select <small>Non-ajax result loading.</small></h1>
</div>
<div class="row">
<div class="span12">
<p>
Countries currently selected: <strong><span
wicket:id="countries-non-ajax"></span> </strong>
</p>
<form wicket:id="multi-non-ajax">
<input wicket:id="countries-non-ajax"
type="hidden" style="width: 300px;" />
<div class="form-actions">
<button type="submit" class="btn">Submit</button>
</div>
</form>
</div>
</div>
</section>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -37,14 +36,12 @@ public class HomePage extends WebPage
@SuppressWarnings("unused")
private Country country = Country.US;
@SuppressWarnings("unused")
private List<Country> countries = new ArrayList<>(Arrays.asList(new Country[] { Country.US,
Country.CA }));
private List<Country> 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<Void>("single");
Expand All @@ -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<Void>("single-non-ajax");
add(nonAjaxform);
Select2Choice<Country> nonAjaxCountry = new Select2Choice<>("country-non-ajax",
new PropertyModel<Country>(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<Void>("multi");
Expand All @@ -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<Void>("multi-non-ajax");
add(nonAjaxMulti);

countries = new Select2MultiChoice<>("countries-non-ajax",
new PropertyModel<Collection<Country>>(this, "countries"),
Arrays.asList(Country.values()), new CountriesRenderer());
countries.getSettings().setMinimumInputLength(1);
countries.add(new DragAndDropBehavior());
nonAjaxMulti.add(countries);
}

/**
Expand All @@ -105,11 +80,8 @@ public HomePage()
*/
private static List<Country> queryMatches(String term, int page, int pageSize)
{

List<Country> result = new ArrayList<>();

term = term.toUpperCase();

final int offset = page * pageSize;

int matched = 0;
Expand Down Expand Up @@ -175,12 +147,4 @@ public Collection<Country> toChoices(Collection<String> ids)
}
}

private static class CountriesRenderer extends ChoiceRenderer<Country>
{

public CountriesRenderer()
{
super("displayName");
}
}
}
Loading

0 comments on commit 1fc93db

Please sign in to comment.