Friday, September 16, 2016

Re: Do something when clicking on suggestion

Hi Olar,

I am not an expert about suggestions but I had read that multiwordsuggestOracle wasn't good for retrieving data from a database but must see SuggestOracle instead.
Did you implemented the getDBSuggestion() or in fact want to know how to implement it perhaps ?
Is your problem that when typing a character nothing happens ?

More explanation could help the readers to help you maybe

Eddy

Le jeudi 15 septembre 2016 17:08:10 UTC+2, Olar Andrei a écrit :
Hello everybody,

I have sort of a conversation system integrated in my application. The class ConversationWidget represents the main widget for the conversation system.
Somewhere there I have a suggestion box, which I want to use to search through all the available conversations based on some patterns, like subject, user, and so on.

I want, when the suggestion is clicked, to parse the String, and to open the desired conversation. The ideea is, that I have some methods in my ConversationWidget class, like viewConversation(int id, final SimplePanel convPanel) which repaints the convPanel with the new conversation.

What would be a way to implement that ? To call viewConversation() in my ConversationWidget based on which Suggestion is clicked?

Thanks in advance,
Andrei

public class ConversationWidget extends Composite implements CustomWidget {

        public ConversationWidget(UserInfo userInfo) {
this.userInfo = userInfo;

initWidget(initializeWidget());
}

        @Override
public Widget initializeWidget() {
            .
            .
            .

                MultiWordSuggestOracle oracle = getDBSuggestions(); // Suggestions come from the DB

final CustomTexBox searchBox = new CustomTexBox();
searchBox.getElement().getStyle().setMarginTop(15.0, Unit.PX);
searchBox.getElement().getStyle().setMarginRight(10.0, Unit.PX);

CustomSuggestionDisplay display = new CustomSuggestionDisplay();
SuggestBox suggestBox = new SuggestBox(oracle, searchBox, display);
            .
            .
            .
        }
}

public class CustomSuggestionDisplay extends SuggestBox.DefaultSuggestionDisplay {

@Override
protected void showSuggestions(SuggestBox suggestBox, Collection<? extends Suggestion> suggestions, boolean isDisplayStringHTML,
boolean isAutoSelectEnabled, SuggestionCallback callback) {

callback = new SuggestionCallback() {

@Override
public void onSuggestionSelected(Suggestion suggestion) {
                          // TODO
}
};

super.showSuggestions(suggestBox, suggestions, isDisplayStringHTML, isAutoSelectEnabled, callback);
}

}


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment