RR: SuggestBox uprades

75 views
Skip to first unread message

Emily Crutcher

unread,
Apr 29, 2008, 5:25:06 PM4/29/08
to Google Web Toolkit Contributors
Below are the  SuggestBox API modifications under consideration. Feedback is very welcome.

                 Thanks,

                            Emily
  • Make SuggestBox depend upon a  DropDownPanel to control its popup, allowing users to customize the behavior, including where it is located and what item is selected by default.
  • Add a requestDefaultSuggestions method to the SuggestOracle, use it in SuggestBox.
  • Add hideSuggestions()/showSuggestions() method
  • Add a new RPCSuggestOracle which, if extended from, guarantees that only one request can be extent at once.
  • Add HighlightHandler support to SuggestBox

P.S The attached patch is against the gwt-incubator, as gwt itself is under feature lock down.  The only changes to SuggestOracle and MultiWordSuggestOracle is the inclusion of the method requestDefaultSuggestions().


"There are only 10 types of people in the world: Those who understand binary, and those who don't"
suggestBoxUpgrades.patch

Isaac Truett

unread,
May 1, 2008, 1:36:56 PM5/1/08
to Google-Web-Tool...@googlegroups.com
I had been thinking about implementing something similar to
RPCSuggestOracle to reduce the RPC traffic in an application that
makes heavy use of SuggestBox. Your implementation is working quite
well for me. The only thing I found awkward was adding calls to
setSuggestWidget(), but that's a small price to pay.

I haven't had a chance to try out any of the other changes.

John LaBanca

unread,
May 1, 2008, 1:41:04 PM5/1/08
to Google-Web-Tool...@googlegroups.com
Emily explained the call to setSuggestWidget to me.  Basically, the SuggestBox takes a SuggestOracle, but the RPCSuggestOracle takes the SuggestBox.  So, you need to pass the RPCuggestOracle into the SuggestBox constructor when you create the suggestBox, and then you can pass it the instance back into the RPCSuggestOracle.
--
Thanks,
John LaBanca
jlab...@google.com

Isaac Truett

unread,
May 1, 2008, 2:21:19 PM5/1/08
to Google-Web-Tool...@googlegroups.com
Yes, I understand the why of it. I've run into (and written)
co-dependencies like that in the past. What about adding a SuggestBox
(Or HasText) reference to Request, similar to the "source" or "origin"
of an event?

Isaac Truett

unread,
Dec 20, 2008, 10:36:43 PM12/20/08
to Google-Web-Tool...@googlegroups.com
Whatever happened to this change? I noticed issue #2739 requesting
hideSuggestions() and this patch would seem to satisfy that request.
Is there any chance of this patch or something similar making 1.6?

John LaBanca

unread,
Dec 22, 2008, 10:20:36 AM12/22/08
to e...@google.com, Google-Web-Tool...@googlegroups.com
[+ecc] to make sure this shows up in her inbox

I think we cut this out of the plans for GWT 1.6 because the DropDownPanel wasn't ready for prime time.  I'm not sure about the status of the RPCRequestOracle, so that might still be on the table.

Thanks,
John LaBanca
jlab...@google.com

Isaac Truett

unread,
Dec 22, 2008, 10:30:45 AM12/22/08
to jlab...@google.com, Google-Web-Tool...@googlegroups.com, e...@google.com
Thanks, John. Would some SuggestBox updates, sans DropDownPanel, be
possible? Here's my holiday SuggestBox API wishlist:

1. showSuggestions() and showSuggestions(String query) - basically the
same as this patch.
2. hideSuggestions() - the same as this patch.
3. selectItem(int index) - select an item from suggestion menu.
4. getSuggestionMenuSelectedItemIndex() - the index of the selected
suggestion menu item.
5. isShowingSuggestions() - Is the suggestion menu open?
6. doSelectedItemAction() - public delegate method to
suggestionMenu.doSelectedItemAction().

I can provide a patch for these if the concepts meet with approval.

- Isaac

Damon Lundin

unread,
Dec 23, 2008, 8:30:55 AM12/23/08
to Google Web Toolkit Contributors
I have a couple more suggestions if I may. The current SuggestBox is
not very friendly when it comes to entering values that are not
suggestions (it's a text field, not a drop list after all).

1) My first suggestion is to deal with the fact that you cannot enter
a non-suggested value if that value is the prefix of something else
suggested by the oracle. This happens because as soon as the popup
appears, the first item in the list is selected and if the user hits
Enter, then this value is chosen instead of whatever the user has
typed.

The solution for this is to add a flag (say selectedByDefault) that
conditionally called "suggestionMenu.selectItem(0);" in
SuggestBox.java. It might be a good idea to also have the SuggestBox
deselect the current value if the user keeps typing. This would deal
with the case where the user types something, uses the arrow keys to
select a value, then keeps typing some more and finally presses Enter
on a non-suggested value.

2) The second case is to deal with the SuggestBox not allowing the
enter key to be used to process a non-suggested value. To process
results from the SuggestBox, a user would typically add a
SuggestionHandler (that's needed to handle mouse clicks). If I want
to be able to process the value entered by the user for a non-
suggested value, then I would also add a KeyboardListener and handle
the ENTER key. The problem is that if the user presses ENTER to
select a value from the popup, then both handlers get fired and the
result gets processed twice.

Once solution to this is to modify the keyboard listener in SuggestBox
so that it fires a SuggestionHandler even when there are no
suggestions. This may result in unexpected behavior and is certainly
not backwards compatible. Perhaps a second parameter could be added
to onSuggestionSelected that indicates if the suggestion was from the
popup or not.

There is one workaround that can be used now but I think is more of a
hack than a solution. In my SuggestionHandler, I can call
"DOM.eventGetCurrentEvent()" and if the Event was a keypress for ENTER
then don't do anything and assume that I added another keyboard
listener that will handle it.

3) And a final note ;-) I don't know if there's another thread to
take this into, but I want to say that I don't want to see you guys
making methods or classes final (why is SuggestBox final?). It makes
it harder for people like me to address situations that you guys
didn't think of or didn't have time to address in development. I
would rather see you make a backwards-incompatible change (documented
of course) than prevent me from working around a problem. In fact, I
think it should be recommended GWT development practice to make
frequent use of small protected methods to allow developers to tweak
the behavior of a GWT class when needed. For example, it would be
great if in SuggestBox.addKeyboardSupport, if the code in the case
statements called individual protected methods (e.g. onKeyDownEnter())
instead of just the code that is there now.

Emily Crutcher

unread,
Dec 29, 2008, 10:06:59 AM12/29/08
to Google-Web-Tool...@googlegroups.com, jlab...@google.com
This is not a promise, but here is what is on my list for the first round of SuggestBox upgrades, which I hope to do as soon as we've finished everything critical for 1.6 (hence why it is not a promise). The others  probably need more design vetting, so are somewhat unlikely to make it in.
  1. Remove final from SuggestBox.
  2. Add showSuggestions()/hideSuggestions()/isShowingSuggestion methods.
  3. Add showDefaultSuggestions()
  4. Wire up SuggestBox to use Popup Panel's showRelative method.
  5. Make escape key close the suggestion popup.
  6. (Stretch goal) rework MultiWordSuggestOracle to be more extensible.
--
Reply all
Reply to author
Forward
0 new messages