Okay. Just one more question.

I have a domain model (HrpBbheerk) which contains a Short column. I would
like to fill this via Select2Choice.
I read the select2-examples but not able to get rid it.

So the steps I took.

1. Fill my hepar5list list from my domain model (HrpBbhepar5). This contains
couple of columns but I only need for two. One for value and one for
description. If possible I don't want to create another wrapper class just
for this case.
2. Create a form, added a model (HrpBbheerk)
3. Added a new Select2Choice to the form with that Short column mentioned
above.

Snippets:

...
        fillHepar5(); // step 1
        HrpBbheertk heertk = fillHeertk();      
        IModel model=new CompoundPropertyModel(heertk);
        sform.setModel(model);  // step 2
        Select2Choice dimelemert = new Select2Choice("dimelemert",new
PropertyModel(sform.getModel(),"dimelemert"),new Hepar5Provider());  // step
3

......

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

        List<HrpBbhepar5> result = new ArrayList<HrpBbhepar5>();
        term = term.toUpperCase();

        final int offset = page * pageSize;

        int matched = 0;
        
        for (HrpBbhepar5 hepar5 : hepar5list) {
            if (result.size() == pageSize) {
                break;
            }

            if (hepar5.getDertekmegnev().toUpperCase().startsWith(term)) {
                matched++;
                if (matched > offset) {
                    result.add(hepar5);
                }
            }
        }
        return result;
    }
    
    
    public class Hepar5Provider extends TextChoiceProvider<HrpBbhepar5> {

        @Override
        protected String getDisplayText(HrpBbhepar5 choice) {
            return choice.getDertekmegnev();
        }

        @Override
        protected Object getId(HrpBbhepar5 choice) {
           return choice;
        }

        @Override
        public void query(String term, int page, Response<HrpBbhepar5>
response) {
            response.addAll(queryMatches(term, page, 10));
            response.setHasMore(response.size() == 10);
        }
        
        @Override
        public Collection<HrpBbhepar5> toChoices(Collection<String> ids) {
            ArrayList<HrpBbhepar5> hepar5idlist = new
ArrayList<HrpBbhepar5>();

            Iterator it = hepar5list.iterator();
            while (it.hasNext()) {
                HrpBbhepar5 h = (HrpBbhepar5) it.next();
                hepar5idlist.add(h);
            }
            return hepar5idlist;
        }
    }

.....

It complains that java.lang.Short cannot be cast to
hu.xxx.model.HrpBbhepar5.
Please let me know what  should I do.

thnx., Sandor








--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/select2-localization-questions-tp4651732p4651753.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Reply via email to