Currently you cannot do at the server-side and you must implement a widget for that one and query the data from server. That is what I did with the
VAutoCompleteTextField.java (client-side) and
AutoCompleteTextField.java (server-side). And I would say this was relatively easy.
The positioning based on the cursor position is the hardest part as there is no direct API for that. Otherwise you can copy the code (or the just the idea) from the
VAutoCompleteTextField.java for this too.
My only obstacle was the newer Vaadin Version that I am using (6.2.6). The component didn’t work out-of-the-box, so I had to change the code a little bit.
I had to:
Remove the getTag() method, because it hat compile errors due to API changes (getTag() is deprecated now)
Instead, I added the annotation “@ClientWidget(value = VSuperImmediateTextField.class)” to the class
Then, I adapted the ComponentsApplicationWidgetset class in the sub-package “client”
Now I can use the text field and execute some actions on key events. Great!!!
By now, I’m displaying a windows with a listbox when the user enters some characters. Depending on the input, the elemets of the listbox changes. So it works as I expected.
What I didn’t understand is the steps to perform, when adding a custom widget or many custom widgets to my application.
For example, I have added this SuperImmediateTextField and it has a “ComponentsApplicationWidgetset.gwt.xml” with the new entry point. That’s OK. (Do I really need this *.gwt.xml file?)
But what if I add another widget and another one? Is there a good description, how this structure is built and how it works? Every widget has its own “entry point”, but do I have to merge them all into one widgetset in order to use them all with one entry point? Probably the explanation is very easy and I’m thinking too complicated.
Hmm… seems that you have come across a old version of SuperImmediateTextField. The most current one should already have @ClientWidget instead of getTag().
Anyhow, yes, you need to have a gwt.xml which combines all the components widgetsets into one. it has one tag for the main widgetset in vaadin, and then a for every custom component that you use, so you get a list of all of them.
This is used by gwt so that it knows what to include into the java to javascript conversion upon compilation. I don’t have a instructions page with more info about this directly. Have to look around a little.
When I had these 3 widgets, like you have listed them in your example, what will be the entry-point?
As in your example, it seems that I don’t need to define one entry-point. So, does the framework just see all the widgetsets and compile? Can I ignore the "entry-point?
You’re right, in most cases you don’t need an entry point when developing custom widgets in Vaadin. You also shouldn’t need to touch the gwt.xml -file, it should be modified by the widgetset build process automatically.
Things changed in 6.2 so that you should not use your own entry-point in widgetsets. GWT will pick up the one from vaadin core. Widgets from inherited modules are collected to your applications “widgetset” by GWT generator automatically.
Autocomplete jar was removed from svn in rev 10970. Why it happened ? Will this component be developed and supported in future ?
I am a new in Vaadin and I am looking for something like GWT’s SuggestBox class. I am creating user-view with a search form. One of forms fields is editable combobox with a 40000 elements(city names). I want to show to a user all correct possibilities after he enter 3 first characters. for example: he will enter 3 chars: “Lon” and the component will show all possibilities (London and others).
I do not want to load at start all 40k elements, so it looks using Autocomplete will be good idea.
I know this is an old thread, and I’m sorry to resurrect it, but this seems like the right place.
The combo box is a good answer for cases where there isn’t much overhead on the server side to returning an item in the container given an ID. But sometimes the overhead here can be too much. Or at least that’s my perception.
Auto completion with a defined interface to produce matching server-side results is a feature that I think Vaadin really needs in core. I will look into developing it, if there’s interest.
Hi Aladdin, can you post the code you made for your combination of supper immediate text field and auto complete text field pls. I am looking for a Vaadin component that functions like google search field.
Hi Guys, I also tried merging the superimmediatefield with the autocompletefield. I got the following to work, but still a few kinks to work out. Maybe other can work on it. Just implemented the keyup listener with a timer in the autocompletefield. I haven’t renamed the packages. 13202.xml (118 Bytes) 13203.zip (6.76 MB)
private String id;
private String value;
public AutoSuggestResultBean() {
super();
}
public AutoSuggestResultBean(String id, String value) {
this();
this.id = id;
this.value = value;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
[/code]When implementing:
CAutoSuggest workOrderSuggestFld = new CAutoSuggest();
workOrderSuggestFld
.setResultsTableValues(new AutoSuggestResultsetBuilder() {
@Override
public List<AutoSuggestResultBean> getResultset() {
return myMethodReturnsAListOfAutoSuggestResultBean();
}
})
This works currently, it’s not an addon, just customized a few classes. Would be really happy if someone could improve the code. By the way built with vaadin 6. Just change the listeners and I guess it’ll work for vaadin 7.