Sorry for this basic question, but can anyone point me to a basic example of a combobox with autocompletion?
tia!
Sorry for this basic question, but can anyone point me to a basic example of a combobox with autocompletion?
tia!
Last edited by olorin; Jul 15th, 2010 at 02:58 AM.
I've got plenty of java and Chesterfield Kings
Donald Fagan - The nightfly
Hello, not sure if it is what you desired for because I am solving the same problem so here is what I have got
public class CarForm extends AbstractForm{
private List carTypes;
protected JComponent createFormControl() {
carTypes = carDao.getCarTypes();
TableFormBuilder formBuilder = new TableFormBuilder(getBindingFactory());
JComboBox box = new JComboBox(carTypes.toArray());
formBuilder.add("carType", box);
formBuilder.row();
return formBuilder.getForm();
}
Suppose the best way to accomplish that goal should be
JComboBox box = getComponentFactory().createComboBox();
but now I am lost
Sorry for not being clear. With an autocompleting combobox i mean a menu that is linked to a text field. If you type in the textfield, the combobox shows a subset starting with the same string (or gets positioned automatically at the location of a menu item starting with this string)
I've got plenty of java and Chesterfield Kings
Donald Fagan - The nightfly
So lets make it right.
In richclient-application-context do the following:
<bean id="applicationServices" class="org.springframework.richclient.application. support.DefaultApplicationServices">
<property name="formComponentInterceptorFactoryId">
<idref bean="formComponentInterceptorFactory" />
</property>
<bean>
<bean id="formComponentInterceptorFactory"
class="org.springframework.richclient.form.builder .support.ChainedInterceptorFactory">
<property name="interceptorFactories">
<list>
<bean class="org.springframework.richclient.list.ComboBo xAutoCompletionInterceptorFactory" />
</list>
</property>
</bean>
Now when I type h in the combobox textfield honda will be marked
Err.. does that work with the code you supplied?
I had the app context settings allright.
But, for starters, i can not start to type if i do not make my combobox editable.
And then I would imagined that i would have needed to implement a listener of some sort to modify the menu upon typing.
I've got plenty of java and Chesterfield Kings
Donald Fagan - The nightfly
But, for starters, i can not start to type if i do not make my combobox editable.
And then I would imagined that i would have needed to implement a listener of some sort to modify the menu upon typing.
I am not sure if we mean the same thing. I suppose you would like to acomplish this task. You must choose a value from the combobox menu. So you can click the arrow icon next to the combobox textfield and click the selected value or you start typing into the combobox textfield and only the values corresponding to the entered text will appear or will be marked. If it is so then that code I gave you is working. Suppose you already read it because there is a very few tutorials for rcp but check this pdf.
http://www.doclo.be/lieven/SpringRichClient.pdf
In the opposite case try to describe it more specifically.
Thanks a lot marekto.
The code I inherited was way more complex than your example with bindings, valueholders and comboboxes created separatly, and not working in harmony afterwards.
(my combobox has contents that needs be reloaded from the db at times and it has a child combobox that needs to be updated when the selected value in my combobox changes).
Starting from your example I got it working alright.
Thanks a lot!!
(FYI createFormControl Code now looks like this:
...
// values refreshable from db
orgList = new RefreshableValueHolder(new organizationValues(),
false,
false);
ComboBoxBinding orgCBB = (ComboBoxBinding) bf.createBoundComboBox(
"organization",
orgList);
orgCBB.setEmptySelectionValue(ORG_NOT_SELECTED);
orgCB = (JComboBox) formBuilder.add(orgCBB, "align=left")[1];
// itemlistener updates child combobox
orgCB.addItemListener(new orgCBListener());
I've got plenty of java and Chesterfield Kings
Donald Fagan - The nightfly
you are welcome, Olorin. Glad I could help you. Also thanks for your example, very useful for me.