users@woodstock.java.net

Re: autocomplete feature for textfield not working?

From: Bill Edwards - Sun BOS Software <Bill.Edwards_at_Sun.COM>
Date: Wed, 02 Apr 2008 09:57:44 -0400

Well, I was doing a prototype using a PHP backend to see if we could run the
Woodstock textField autocomplete as a client-side widget without a JSF
backend.
So this might be a different enough environment that I'm not seeing whatever
problem you are encountering, especially if its related to the Ajax call
back to
the server's JSF component via DynamicFaces. My prototype did use the
Dynafaces Ajax layer, so my client side javascript should be similar to what
you are doing. But the server side is completely different.

Can you confirm the Dynafaces XHR call occurred? You can use Firebug
(in Firefox) to monitor the request/responses, or perhaps server side debug
tracing in Tomcat or App Server (whichever you might be using). Basically,
confirm the XHR call is getting made.

You could also make sure the jsfx=true and webuiJsfx=true attributes are
set in the webuijsf:head tag. This is not required, I think, but
cannot hurt
(I used these settings to make sure the Dynafaces javascript was loaded
upfront).

autozoom wrote:
> I think I made things right as explained by the documentation. The problem
> here is that I don't even see any ajax call while typing, so the issue is
> not on the code side I guess.
>
> Can you explain how you got it to work please?
>
>
> Bill Edwards - Sun BOS Software wrote:
>
>> I have been able to make it work using in my PHP test. This was
>> version 4.2.
>>
>> Cathy Mucci wrote:
>>
>>> I'm not sure if this will help or not. I received this info a few
>>> days back on adding autocomplete code to a test I'm working on:
>>>
>>> From Dmitry:
>>>
>>> Using autocomplete is 2-step process. See attachment below for
>>> excerpts from TLD docs, but in short autoComplete and
>>> autoCompleteExpression must be defined.
>>>
>>> In order to use it, fields must be bound like this:
>>> autoComplete="true"
>>> autoCompleteExpression = "#{AutoCompleteBean.getOptions}"
>>>
>>> where AutoCompleteBean is
>>> <managed-bean>
>>> <description>The backing bean for the field autoComplete
>>> example</description>
>>> <managed-bean-name>AutoCompleteBean</managed-bean-name>
>>>
>>> <managed-bean-class>autocomplete.AutoCompleteBean</managed-bean-class>
>>> <managed-bean-scope>session</managed-bean-scope>
>>> </managed-bean>
>>>
>>>
>>> "Attribute indicating to turn on/off the autocomplete functionality of
>>> the TextField. Autocomplete would trigger the AJAX request to the
>>> component.
>>>
>>> Autocomplete will submit the content of the text field for server side
>>> processing that will be processed using JSFX partial lifecycle cycle.
>>> Providing of autoComplete options remains responsibility of the
>>> developer. Specifically, autoCompleteExpression needs to be set
>>> By default autocomplete is off."
>>>
>>> and for autoCompleteExpression :
>>>
>>>
>>> " Use the autoCompleteExpression to specify the method that will
>>> filter an autoCompleteExpression list, i.e. to produce new set of
>>> options to be rendered as autoComplete prompts ( see
>>> autoCompleteExpression) . When autoComplete mechanism is enabled ( by
>>> specifying autoComplete attribute), autoCompleteExpression method will
>>> be called using the Ajax mechanism in the background every time user
>>> changes the content of the field. Note that this requires
>>> autoCompleteExpression method to perform well. Also, it is recommended
>>> to limit number of options available to user as the return of this
>>> method - both for usability and in order to increase download speed.
>>>
>>> The value of autoCompleteExpression must be an EL expression and it
>>> must evaluate to the name of a public method that is defined by
>>> com.sun.webui.jsf.model.AutoComplete, something like: public Options[]
>>> getOptions(String filter) { ... } In this example, expression would
>>> look like this: < webuijsf:textField autoComplete = "true"
>>> autoCompleteExpression ="#{AutoCompleteBean.getOptions}"
>>> text="#{AutoCompleteBean.text}" label = "AutoComplete" id = "tf" />
>>>
>>> "
>>>
>>>
>>> autozoom wrote:
>>>
>>>> hello,
>>>> I tried the autocomplete function in 4.2 build 5, like this:
>>>>
>>>> <webuijsf:textField autoComplete="true" id="textField1" style="position:
>>>> absolute; left: 180px; top: 252px"
>>>> autoCompleteExpression ="#{Page1.getOptions}"/>
>>>>
>>>> where
>>>> public Option[] getOptions(String filter) {
>>>> Option[] ret = new Option[3];
>>>> ret[0] = new Option(1L, "uno");
>>>> ret[1] = new Option(2L, "due");
>>>> ret[2] = new Option(3L, "tre");
>>>> return ret;
>>>> }
>>>>
>>>> but nothing happens when typing in the textfield; it doesn't seem to
>>>> be a
>>>> problem of code, it just doesn't fire any ajax call when typing
>>>>
>>>> what am I missing?
>>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
>> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>>
>>
>>
>>
>
>