You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Madasamy mcruncher <ma...@mcruncher.com> on 2012/11/30 05:31:00 UTC

select2 integration -Duplicate(selected) value are appear in drop down box

we are using select2 version 2.0  in our application.
Select2MultiChoice field are using for select a multiple value. here we set
the
"maximumselectionsize" is 20. and set "minimuminputlength" is 1.when we
give input in that field the relevant value are appear in drop down box
correctly,
if selection count reach  15 or 16, hence we give input in that field the
duplicated
(selected) value are appear in the drop down box.

but i could not recreate this problem in Myquickstart.

the sample code is

        Select2MultiChoice<Foo> fooField = new
Select2MultiChoice<Foo>("message",
              new PropertyModel<Collection<Foo>>(this, "foo"), new
FooProvider);
        fooField.getSettings().setMinimumInputLength(1);
        fooField.getSettings().setMaximumSelectionSize(20);
        fooField.setRequired(true);
        return fooField;

Re: select2 integration -Duplicate(selected) value are appear in drop down box

Posted by Thomas Götz <to...@decoded.de>.
I can't detect anything wrong with your implementation on first sight. Is it possible that you can reproduce the described behavior in a Quickstart?

  -Tom


On 01.12.2012, at 03:09, Madasamy mcruncher <ma...@mcruncher.com> wrote:

> FooProvider implementation is
> 
>    public class FooProvider extends TextChoiceProvider<Foo>
>    {
> 
>       FooService fooService=new FooService();
>       @Override
>        protected String getDisplayText(Foo fooChoice) {
>            return fooChoice.getName();
>        }
> 
>        @Override
>        protected Object getId(Foo fooChoice) {
>            return fooChoice.getName;
>        }
> 
>        @Override
>        public void query(String term, int page, Response<Foo> response) {
>            response.addAll(queryMatches(term, page, 10));
>            response.setHasMore(response.size() == 10);
> 
>        }
> 
>        @Override
>        public Collection<Foo> toChoices(Collection<String> ids) {
>            ArrayList<Foo> foos = new ArrayList<Foo>();
>            for (String id : ids) {
>                foos.add(fooService.findFooByName(id));
>            }
>            return foos;
>        }
>    }
> 
> private List<Foo> queryMatches(String term, int page, int pageSize) {
> 
>        List<Foo> result = new ArrayList<Foo>();
>        term = term.toUpperCase();
>        final int offset = page * pageSize;
>        int matched = 0;
>        for ( Foo foo : getAllFoos()) {
>            if (result.size() == pageSize) {
>                break;
>            }
> 
>            if (foo.getName().toUpperCase().contains(term)) {
>                matched++;
>                if (matched > offset) {
>                    result.add(foo);
>                }
>            }
>        }
>        return result;
>    }
> 
>    public List<Foo> getAllFoos()
>    {
>        //return all foos
>        return fooService.findAll();
>    }


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: select2 integration -Duplicate(selected) value are appear in drop down box

Posted by Madasamy mcruncher <ma...@mcruncher.com>.
FooProvider implementation is

    public class FooProvider extends TextChoiceProvider<Foo>
    {

       FooService fooService=new FooService();
       @Override
        protected String getDisplayText(Foo fooChoice) {
            return fooChoice.getName();
        }

        @Override
        protected Object getId(Foo fooChoice) {
            return fooChoice.getName;
        }

        @Override
        public void query(String term, int page, Response<Foo> response) {
            response.addAll(queryMatches(term, page, 10));
            response.setHasMore(response.size() == 10);

        }

        @Override
        public Collection<Foo> toChoices(Collection<String> ids) {
            ArrayList<Foo> foos = new ArrayList<Foo>();
            for (String id : ids) {
                foos.add(fooService.findFooByName(id));
            }
            return foos;
        }
    }

 private List<Foo> queryMatches(String term, int page, int pageSize) {

        List<Foo> result = new ArrayList<Foo>();
        term = term.toUpperCase();
        final int offset = page * pageSize;
        int matched = 0;
        for ( Foo foo : getAllFoos()) {
            if (result.size() == pageSize) {
                break;
            }

            if (foo.getName().toUpperCase().contains(term)) {
                matched++;
                if (matched > offset) {
                    result.add(foo);
                }
            }
        }
        return result;
    }

    public List<Foo> getAllFoos()
    {
        //return all foos
        return fooService.findAll();
    }

Re: select2 integration -Duplicate(selected) value are appear in drop down box

Posted by Thomas Götz <to...@decoded.de>.
Can you please post your FooProvider implementation?

   -Tom

On 30.11.2012, at 05:31, Madasamy mcruncher <ma...@mcruncher.com> wrote:

> we are using select2 version 2.0  in our application.
> Select2MultiChoice field are using for select a multiple value. here we set
> the
> "maximumselectionsize" is 20. and set "minimuminputlength" is 1.when we
> give input in that field the relevant value are appear in drop down box
> correctly,
> if selection count reach  15 or 16, hence we give input in that field the
> duplicated
> (selected) value are appear in the drop down box.
> 
> but i could not recreate this problem in Myquickstart.
> 
> the sample code is
> 
>        Select2MultiChoice<Foo> fooField = new
> Select2MultiChoice<Foo>("message",
>              new PropertyModel<Collection<Foo>>(this, "foo"), new
> FooProvider);
>        fooField.getSettings().setMinimumInputLength(1);
>        fooField.getSettings().setMaximumSelectionSize(20);
>        fooField.setRequired(true);
>        return fooField;


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org