All of the information that I can find for SuggestBox and MultiWordSuggestOracle suggests that the only way to set an oracle for a suggest box is when it is constructed. I don't think this makes sense, though, since there is a default constructor that does not accept an oracle and creates one for you, presumably empty. That doesn't do much good. What I'm looking for would be methods like setSuggestOracle(MultiWordSuggestOracle)
or addToSuggestOracle(String)
, but I can't find anything in the documentation suggesting how to do this.
It doesn't look like you can change the instance of the SuggestOracle
after the SuggestBox
has been created, but you can access it with SuggetBox::getSuggestOracle()
. From there you would have to cast to the implementing class to make changes to it; the SuggestOracle
base class itself doesn't provide anything. So something like:
SuggestOracle oracle = new MultiWordSuggestOracle();
SuggestBox box = new SuggestBox(oracle);
try {
MultiWordSuggestOracle multiWordOracle = (MultiWordSuggestOracle)box.getOracle();
multiWordOracle.add("This awesome suggestion.");
} catch (ClassCastException e ) {
// the oracle was not what you thought it was
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With