Skip to main content

[JMaki widget] scriptaculous.autocompleter problem with service

4 replies [Last post]
mediii
Offline
Joined: 2007-09-03

Hello all,

I need to provide a service for the completer to use. Defaulting an _autocomplete.html file is present in the widget directory. but i want to replace it with an ArrayList object witch is builded from a data base,

here is my javascript code in component.js
----------------------------------------------------------------------------------------------------------------
...
jmaki.widgets.scriptaculous.autocompleter.Widget = function(wargs) {
var servicei = wargs.service;
if (!wargs.service){
jmaki.log("You did need to provide a service for the completer to use. Defaulting to an _autocomplete.html file in the widget directory.");
servicei = wargs.widgetDir + "/_autocomplete.html";
}

this.wrapper = new Ajax.Autocompleter(wargs.uuid, wargs.uuid + '_target',
servicei,
{tokens: new Array(',','\n'), fullSearch: true, partialSearch: true}
);
----------------------------------------------------------------------------------------------------------------

and in my jsf page :

----------------------------------------------------------------------------------------------------------------
...

----------------------------------------------------------------------------------------------------------------

and in the Bean.java :

-----------------------------------------------------------------------------------------------------------------

public class Bean {

private List myArray = new ArrayList();

public ChangeLocaleBean(){
myArray.add(new SelectItem("John Jackson","John Jackson"));
myArray.add(new SelectItem("Jack Johnson","Jack Johnson"));
myArray.add(new SelectItem("Jane Agnews","Jane Agnews"));
}

public List getMyArray() { return myArray;}
public void setMyArray(List myArray) { this.myArray = myArray; }

}
---------------------------------------------------------------------------------------------------------------

i have a problem because the autocompletion does not work, my question is what types are supported for service attributes, can i use a String[], Array, Vector, ResultSet ?

in the log i have this for

jmaki.log(servicei); -> http://localhost:8080/WebApplication/faces/bean-myArray.ajax

is it a conversion problem ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
a_laksmana
Offline
Joined: 2007-11-01

So what's the right data model? I can't get it to work. This is what I did:

name="scriptaculous.autocompleter"
service="./page_user_getfirstnames.jsp" />

inside the page_user_getfirstnames.jsp is:
<%
out.println("['test1', 'test2', 'TEST3']");
%>

Anyway, I'm using dojo combo box now. It works and serves the same purpose. :)

Message was edited by: a_laksmana

gmurray71
Offline
Joined: 2003-07-31

HI,

Currently we have not created a data model for the scriptatculous autocompleter and it takes plain old HTML as the return. Scriptataculous does a simple replacement if I remember correctly.

Moving forward I would like to follow a data model close to the combobox model which appears at:

http://wiki.java.net/bin/view/Projects/jMakiComboxModel

I've started to move the yahoo.autocompleter for follow the similar model.

A service attribute only supports strings that are URLs.

Use a value attribute to pipe in data like what you are trying to do.

Let us know if this does not work.

mediii
Offline
Joined: 2007-09-03

thanks gmurray71, it works correctly with the value attribute, this attribute only supports a String array in this format (if someone have another array supported by the attribute value for the scriptaculous widget please let me know)

private String chaine = "['element1','element2','element3']"; ---> OK !

List myArray = new ArrayList();
myArray.add(new SelectItem("element1","element1"));
myArray.add(new SelectItem("element2","element2")); ---> Not work !

private String[] myArray2 = new String[]{"element1","element2","element3"}; ----> Not work !!

annanna
Offline
Joined: 2007-10-26

Hi,

can you post a working bean for using the autocompleter (mybe with database access?)

Thanks, Anja