Hell all,
Can anyone tell me which element is best to use as an autocomplete field?
I thought of dijit.form.ComboBox myself.
Can't find good documentation to my liking though how to implement.
I want to use it with java servlet technology.
Regards,
Patrice

you're right -
you're right - dijit.form.ComboBox is probably the one you want. this will allow the user to input their own option or select one from the dropdown list. if you want to limit the options to just the ones in the list then you will want a dijit.form.FilteringSelect.
the implementation is simple. there are a number of resources to help you with this.
1. getting dojo working - http://sitepen.com/labs/guides/?guide=DojoQuickStart or http://dojotoolkit.org/book/dojo-book-0-9/part-1-life-dojo/quick-install...
2. the ui/client - http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/form-validation-s... this shows the different form widgets that are available and examples of how to implement each one. for the ComboBox, look at the dojo.Data-Enabled ComboBox example on this page http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/form-validation-s... - the dataStore(dojo.data.ItemFileReadStore) is where the ComboBox pulls the options from.
3. the server - point the url of your dataStore(dojo.data.ItemFileReadStore) to a url on your server that will provide data in a json format. for an example, look at http://dojotoolkit.org/files/states.txt which is a static file but shows what format your server should provide.
at first, i would recommend not using dojo programmatically - use the declarative way at first. this will help you see some results quickly and then as you get a better understanding of dojo and a need for more complexity then you may find yourself making a transition towards programmatic.
i was going to provide some code for you but the links i gave you all have examples so let me know if you get stuck and need some more specific help - it helps if you provide any code you might be having trouble with.
working!
thanks for the reply,
I have it working, but it seems the ComboBox comes with a lot of overhead in terms of dojo.requires so i may have to look for a different approach.
In my case bandwith is an issue. I could also do without the tundra makeup for example.
Note: it seems dojo expects json format starting with the Array name 'items' and nothing else.
overhead, themes, data
overhead - dojo has the ability to create a custom build. http://dojotoolkit.org/book/dojo-book-0-9/part-4-meta-dojo/package-syste... with a custom build, you can reduce your overhead by making fewer calls to the server and also by compacting the code using shrinksafe.
tundra - this is not the only theme, there are others and you can always do your own as well. as far as i know, the themes are only cosmetic and the widgets are still functional without one. i know you can write your own custom themes but i believe that they're entirely optional and your functionality is not affected by a lack of a theme - need to verify this.
data - there are a number of different data stores available - take a look at http://api.dojotoolkit.org/jsdoc/dojox/HEAD/dojox.data for some of them. the store most commonly used in examples is the ItemFileReadStore (http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-...) and it's format is json and there are 3 basic attributes - idenitfier, label and items. quoting the book -
identifier
Optional Metadata. The attribute in each item to act as the unique identifier for that item. This parameter is optional.
label
Optional Metadata. The attribute in each item to act as the human-readable label for that item. This parameter is optional.
items
An array of JavaScript objects that act as the items of the store. The attributes that are part of the items can be any valid JavaScript attribute name. Note that there is a special way for items to reference other items in the store when dealing with hierarchical data.
you're right -
i accidentally posted a 2nd time - can someone delete this entry?