Thanks very much.

I'm searching other implementation too.


On 9月29日, 午後4:15, Albert Attard <[email protected]> wrote:
> Hi Everyone:
>
> I need to create a suggestion box where the user will enter a set of
> comma separated categories, very similar to the Gmail address fields,
> and display a list of matching key words for the current entry.
>
> For example, let say I have the following suggestions: car; motor;
> truck; and caravan. When the user enters 'c' the key words 'car' and
> 'caravan' will be listed and the user selects one. Then the user
> enters comma: ',' followed by 't' (so the suggestion box has the text:
> "car, t" with the cursor just after the 't'). Now I want to list all
> the matching key words for 't'. I managed to, sort of, go around this
> as shown below, but as you’ll see it’s flawed.
>
> MultiWordSuggestOracle oracle = new MultiWordSuggestOracle() {
>   private String prefix = "";
>
>   @Override
>   public synchronized void requestSuggestions(Request request,
> Callback callback) {
>     prefix = "";
>     String[] keys = request.getQuery().split(",");
>     if (keys.length > 0) {
>       for (int i = 0; i < keys.length - 1; i++) {
>         prefix += keys[i].trim().toLowerCase() + ", ";
>       }
>       request.setQuery(keys[keys.length - 1]);
>     }
>     super.requestSuggestions(request, callback);
>   }
>
>   @Override
>   protected synchronized MultiWordSuggestion createSuggestion(String
> replacementString, String displayString) {
>     return super.createSuggestion(prefix + replacementString,
> displayString);
>   }};
>
> oracle.add("car");
> oracle.add("motor");
> oracle.add("truck");
> oracle.add("caravan");
>
> SuggestBox categoriesSuggestBox = newSuggestBox(oracle);
>
> The main issue is that I cannot get the cursor position and I can only
> append. So the user cannot change one of the first categories. He/she
> can only append for this to work correctly.
>
> Do you know of any better implementation?
>
> Thanks in advance,
> Albert

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to