Skip to content

Revert non-ajax support#402

Merged
martin-g merged 2 commits into
wicketstuff:masterfrom
tgoetz:master
May 8, 2015
Merged

Revert non-ajax support#402
martin-g merged 2 commits into
wicketstuff:masterfrom
tgoetz:master

Conversation

@tgoetz

@tgoetz tgoetz commented May 4, 2015

Copy link
Copy Markdown
Contributor

As already mentioned on wicket-users mailing list (http://markmail.org/message/w2ynmeguy6szk3uf), I think the current implementation of wicket-select2 in not usable because of commit 1f7aaeb (non-ajax support):

First of all, I think there is no need for a non-ajax wicket-select2 component: if you need a non-ajax select2, simply use a DropDownChoice (or hidden textfield for multichoice) and init select2 directly using Javascript only (select2.js). I could provide a Behavior that handles the JS initialization part.

The current non-ajax implementation uses an ArrayList in addition to the already existing ChoiceProvider, but this breaks the idea behind the ChoiceProvider, now there are two separate ways to provide choices, which is very confusing. Also, users are forced to provide the (static) list of (non-ajax) choices (else the constructor throws exceptions), although they might not be interested in a non-ajax behavior.

If the PR is accepted I will also merge it to the wicket-6.x branch and see what else needs to be merged.

@martin-g

martin-g commented May 4, 2015

Copy link
Copy Markdown
Member

@lehvolk @reiern70 @solomax Ping.

I'm fine with the change/revert.

@reiern70

reiern70 commented May 5, 2015

Copy link
Copy Markdown
Contributor

Hi,

1- This non AJAX can be achieved with a behavior attached to a drop down choice as mentioned by @tgoez

package com.vaynberg.wicket.select2;

import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;

/**

  • Behavior that adds a select2 to a dropdown choice.
    */
    public class Select2Behavior extends Behavior {

    @OverRide
    public void renderHead(Component component, IHeaderResponse response) {
    new Select2ResourcesBehavior().renderHead(component, response);
    StringBuilder builder = new StringBuilder("$('#").append(component.getMarkupId()).append("').select2({});");
    response.render(OnDomReadyHeaderItem.forScript(builder));
    }

    @OverRide
    public void bind(Component component) {
    component.setOutputMarkupId(true);
    }
    }

2- What I find useful is reading content from another sources like mounted resources

ivaynberg/wicket-select2#45

I'm +1 to revert.

martin-g added a commit that referenced this pull request May 8, 2015
[select2] Revert non-ajax support
@martin-g martin-g merged commit 1fc93db into wicketstuff:master May 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants