Announcement Announcement Module
No announcement yet.
Binding 25000 entries to refreshable ComboBox Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding 25000 entries to refreshable ComboBox

    Hello together,

    I tried the whole day to bind a list of Strings to a ComboBox and it seems that I have two problems, that I cannot fix by myself and I'm running ou of time finishing my diploma in spring and spring-rcp...

    First is, that if I bind a list of cities (about 25000 Strings) to a ComboBox it takes about one minute until the gui refreshes... Is it normal, that it takes so long for binding 25000 String values in a list? If I bind only 1000 values it works fine and fast... And if I outcomment the line where the formbuilder adds the comboBox to the form refreshing-speed turns back to normal speed... As I found out its not the creation of the listmodel nor the creation of the comboBox itsself... It seem to hang somewhere in the background, when the DefaultViewDescriptor which contains the form is called to showup...

    here is my code for binding the comboBox:
    ListListModel model = new ListListModel(service.getCities()); // about 25000 on startup
    Binding cityBinding = sbf.createBoundComboBox("", model);
    formbuilder.add(cityBinding, "colspan=1");

    My second problem is, that I want the data in the comboBox being updated (e.g. when the user types in a postcode, the city-combobox will show only the cities, that match the postcode).
    I thought that the gui would update itself when the underlaying data changes, like in all other bound forms. When I call the service with it delivers the right cities and the comboBoxModel has the right size after updating the list, but even if I revalidate and repaint everything in my form manually, the comboBox will not show the updated list. it's empty.

    System.out.println("size: "+model.size()); // holds the right length and the right data after updating the model, but not showing it in gui...
    Is it possible to wire a pre-configured Binding in the apllication-context to safe time on creation?

    greetz, gibelium

  • #2
    25,000 entries

    Don't display 25K entries, how is that usefull? I would not start off with 25K, I would either validate the free text they entered, ot populate the dropdown after all 5 digits of the zip are complete. Also I would look at glazed lists, it is best way to acomplish what you are trying to do.
    Last edited by mlavwilson2; Mar 31st, 2006, 07:51 PM.


    • #3
      thanks for reply,

      thats the way I want it to do and did it in my plain swing prototype... i init the comboBox with a empty ArrayList and insert the filtered Cities only when 5 digits are filled in the postcode field...

      but that leads to the second problem described... i can fill my comboBox model with the filtered arrayList and read the inserted values, but it does not show anything...

      so it seems that i'm missing something which lets the comboBox refresh itself or i'm somewhere referencing the wrong model? i set the combobox background to red for testing purpose, and the color is rendered, but not the new entries...

      greetz, gibelium


      • #4

        it's late here in europe, but i finally came to the solution for my combobox problem... the RefreshableValueHolder was the missing piece...

        by now my postcode-combobox looks like this:
        RefreshableValueHolder citiesHolder;
        citiesHolder = new RefreshableValueHolder(new Closure() {
                    public Object call(Object object) {
                    	if(postcode.length() == 5)
                            return commonService.getCitiesByPlz(postcode);
                    	else return new Object[] {};
                }, true, false); 
                cityBinding = sbf.createBoundComboBox("", citiesHolder);
        in my keylistener i then invoke the combobox-refreshing like this:
        postcode = tfPostcode.getText() + evt.getKeyChar();
        i wonder why the refresh-method does not accept a parameter, because the Closure itself could work with an object as parameter as i saw in the code. in that case i had not to hold my postcode var, but could send the typed postcode directly to the refresh-nethod...

        greetz, gibelium