On Friday, July 13, 2012 10:36:57 PM UTC+2, TimOnGmail wrote:
>
> Hey all...
>
> I was trying to find a way to substitute my own subclass of 
> SuggestOracle.Request in a SuggestBox implementation.  This seems 
> impossible, as the creation of the Request object happens deep in the 
> bowels of the SuggestBox framework.
>
> This is a problem - basically, we have a case where we want to add a "Show 
> More" line to a list of suggestions.  Eg:
>
> [fred]
> Fred1
> Fred2
> Fred3
> Show More...
>
> I can add the "Show More" as a Suggestion, and subclass Suggestion so that 
> it contains the metadata identifying it as a "special" value.
>
> However, when I click on it, the Request object that the SuggestBox 
> framework creates is a plain one, with only a String query and an int limit.
>
> What I'd *like* is for any associated metadata I've added to the 
> Suggestion subclass to be included in the Request object that is generated; 
> even a reference to the original Suggestion object would be fine.  But this 
> data is not available, so all I get is the query and the limit, and nothing 
> else.
>
> Has anyone ever gotten SuggestBox to work the way I want?  Substitute the 
> creation of the Request object with your own implementation/subclass?  It 
> seems a no-brainer that this would be useful, but it's not possible so far 
> as I can see.
>

The "Show more…" use case is already covered by SuggestBox without 
resorting to hacks like returning a special Suggestion: use 
setMoreSuggestions(true) on the Response.

Rendering is then done by the SuggestionDisplay. The 
DefaultSuggestionDisplay ignores the info, but you can provide your own 
SuggestionDisplay. If you don't want to implement one from scratch, you can 
easily add the functionnality to DefaultSuggestionDisplay: override 
decorateSuggestionList to wrap the menu in a container where you add a 
"Show More" button and then override setMoreSuggestions to show/hide the 
button. Alternately, but a bit hackish, you can simply get a handle on the 
widget in decorateSuggestionList and cast to a Menu widget, and in 
setMoreSuggestions dynamically add a "Show More" MenuItem to the menu.
The way you handle the click on "ShowMore" is up to you. You could e.g. 
create a Request with a different "limit", call your SuggestOracle and then 
call showSuggestions of your SuggestionDisplay with the result.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/auJoNrv_Xz4J.
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