Ok, so based on everybody's examples here I managed to get the Autocompleter
working with Seam Remote. What I did was the following:
1. Create a extensions.js in which you extend the scriptaculous
Autocompleter.Base
| SeamAutocompleter = Class.create();
| Object.extend(Object.extend(SeamAutocompleter.prototype,
Autocompleter.Base.prototype), {
|
| initialize: function(element, update, options) {
| SeamRemote.log('SeamAutocompleter.initialize()\n');
| this.baseInitialize(element, update, options);
| },
|
| getUpdatedChoices: function() {
| SeamRemote.log('SeamAutocompleter.getUpdatedChoices()\n');
| var instance = this;
| var callback = function(returnVal) { instance.updateChoices(returnVal);
};
| SeamRemote.create("autoComplete").getSuggestion(this.getToken(),
callback);
| }
|
| });
|
2. Create the Seam Remote component AutoCompleteAction.java with its interface
AutoComplete.java
| @Stateless
| @Name("autoComplete")
| @Interceptors(SeamInterceptor.class)
| public class AutoCompleteAction implements AutoComplete {
|
| public String getSuggestion(String query) {
|
| // You would have a database query to get the actual
| // suggestions based upon the user's input 'query'
| return "<ul><li>option 1</li><li>option 2</li></ul>";
|
| }
|
| }
|
| @Local
| public interface AutoComplete {
|
| @WebRemote
| public String getSuggestion(String query);
|
| }
|
3. Put the scriptaculous input box in your HTML
| <input autocomplete="off" id="contact_name" name="contact[name]" size="30"
type="text" value="" />
| <div class="auto_complete" id="contact_name_auto_complete"></div>
| <script type="text/javascript">
| new SeamAutocompleter('contact_name', 'contact_name_auto_complete',{});
| </script>
|
Don't forget to import the correct JavaScript files in the HEAD section of your
HTML.
Hope this is of any use to anybody as JavaScript debugging can be quite a pain!
:)
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3937529#3937529
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3937529
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user