AJAX autocompletion field - multiple inputs hack
The AJAX auto-Complete Text Field is great, however it only allows one entry to be entered at a time. When a new value is selected from the suggestion list, the text field is cleared automatically.
What I needed to do was like the "Send To" field in gmail, in which you can enter multiple entries in a text field, separated with commas or whatever.
This could be done by editing the javascript file that came with the download. The steps are as follows:
1. Open the \Creator2\nb4.1\samples\complib\ui.complib file with Winzip.
2. Extract the ui.jar file
3. Extract the META-INF\autocomplete\script.js file from ui.jar.
4. Look for "bpui.autocomplete.chooseItem = function(targetName, item)" and change it to the following:
bpui.autocomplete.chooseItem = function(targetName, item) {
if (!bpui.autocomplete.state.onchoose) {
var target = document.getElementById(targetName);
var targetValue = target.value;
if (targetValue.indexOf(',') != -1){
// comma found in original content, append selected item to the end
target.value = target.value + item;
}else{
// if field is empty or there're no commas, replace the original content
target.value = item;
}
target.focus();
} else {
bpui.autocomplete.state.onchoose(item);
}
}
5. Then reverse the steps and put the updated jar files back into ui.complib.
6. Delete previously imported AJAX comp libraries from the Component Library Manager and repeat the steps in http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/aja ximportcomponents.html. Make sure you point to the updated ui.complib file.
You could basically change the behaviour of any of the included AJAX components this way. It's just editing of javascript.

