Thanks for the - ahem - Suggestion, Thomas. :-)

I hadn't known about this functionality; the problem with it, in the 
codebase I'm working in, is that there is no standard among service calls 
(and the actual code doing the database queries within some EJBs) about how 
many rows of data are to be returned.  We have a requirement for a "Show 
more..." suggestion, but also for a "There are too many rows to display, 
please refine your query" suggestion.  Neither suggestion can be driven by 
the server side, it has to be the GUI telling the server "This is a request 
for my concept of the base limit of suggestions" and "This is a request for 
my concept of the MAX limit of suggestions".  The BASE and MAX values will 
differ in different locations in the GUI, even though they might be making 
the same back-end call.

Thus, the GUI has to tell the server "I want 10 suggestions, and that is 
the base request amount"; when "Show more..." is clicked, it has to tell 
the server "I want 20 suggestions, and that is the max request amount".  It 
also needs to tell the server "Actually query for BASE+X, but only return 
BASE suggestions".

I have gotten this to work on the GUI side by creating an extended 
SuggestBox class that modifies it's own limit, and keeps track of if it 
just requested the BASE or MAX amounts.  The problem with this, still, is 
that the server doesn't know how many extra rows to query for.

So it would be nice to be able to pass some more information along with my 
SuggestOracle.Request (as well as the SuggestOracle.Response) that gives 
context to the SuggestBox, so our subclass SuggestBox can be used thoughout 
the GUI, with just BASE, MAX, and X parameters set.

Perhaps I'm missing something - hey, I've done it before :-) - but I still 
feel it would be lovely to be able to pass some more contextual information 
back and forth in the Request and Response objects somehow.  I've worked on 
this by wrapping the SuggestOracle.Request object in another object that 
contains this context (intercepted in requestSuggestions()), and subclassed 
SuggestOracle.Response to wrap this context on the way back.

If you can think of a better way of passing this extra context back and 
forth in a generalized way, however, I'd love to know about it.

- Tim


On Friday, July 13, 2012 7:10:37 PM UTC-7, Thomas Broyer wrote:
>
> 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/-/xcAhfYhexoUJ.
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