Select / ComboBox with specific ID

Hi everybody,

I’m currently testing It Mill, it’s seems to be pretty good and today I have some questions :

  • What is the difference between Select component and ComboBox ?
  • There is a way to add a specific ID associated with a value on ComboBox to return the ID on user selection. (This possibility probably exist but I don’t see it.)

Thanks in advance !

Really good question - there is no difference. ComboBox is just a Select with different set of defaults set. The reasoning why ComboBox exists is just naming - historically (from year 2001) IT Mill Toolkit has tried to use naming that reflects to the abstract purpose of the UI components (selecting from a set in this case). In IT Mill Toolkit 5 we decided to add some convenience classes with more easily identifiable names to make life easier for new users (who are too busy to read any documentation) - ComboBox is just one of those classes :)

Sure. Selects (Select, ComboBox, Table, Tree, …) identify the selected items with itemids. Thus getValue() return the id of the select item or collection of selected item ids (depending on whether we are using the component in single or multiselect mode). If you have not anyhow configured the select, it uses those ids as the names of items drawn to screen. Each item can have any number of properties associated with it. You could for example add property called “visibleText” and then say to your select component setItemCaptionPropertyId(“visibleText”). Another way of achieving the same behaviour is to use setItemCaption().

For more info on this mechanism and different possibilities, see:

Thanks a lot for yours explanations !

hi
i’m new to IT Mill,and i’d like anyone can give me a plain example of how to assign an ID to a Combox item and how to associate value to this ID.
thnx for u all.

Regarding the ComboBox example, here’s a short example from the manual:


/* Create a Select component and add it to a layout. */
Select select = new Select ("Select something here");
main.addComponent(select);
	
/* Fill the component with some items. */
final String[] planets = new String[]
 {"Mercury", "Venus", "Earth", "Mars",
                                       "Jupiter", "Saturn", "Uranus", "Neptune"};
for (int i=0; i<planets.length; i++)
    select.addItem(planets[i]
);

In the code you can change “Select” to “ComboBox” for the ComboBox style select.

More info at
http://itmill.com/documentation/itmill-toolkit-5-reference-manual/components.selecting.html

HTH
/Jonatan