1

I have written a simple Proof-of-Concept application to test out autocomplete fields using Oracle ADF, and although it mostly works the maxSuggestedItems attribute doesn't seem to have any effect. Oracle's documentation indicates that putting a value other than -1 should limit the list of values returned and include a "More..." item at the bottom that will cause the entire list to be returned. Instead, the entire list is always returned.

Is this something I have to implement manually? If so, how would one approach that?

The JSFF page has the following code in it:

<af:inputText label="Accessories:" id="it4">
  <af:autoSuggestBehavior suggestItems="#{accessorySuggest.onAccessorySuggest}"
                          maxSuggestedItems="5"/>
</af:inputText>

The method which returns the suggested values (all hard-coded of course) is as follows:

private static final String[] accessories =
{ "Alloy Wheel", "All-Weather Cargo/Trunk Mat", "All-Weather Floor Mats",
  "Audio Unit - Base", "Audio Unit - Premium", "Auto-Dimming Mirror",
  "Bluetooth", "Body Side Moldings", "Capert Floor Mats - Premium",
  "Car Cover", "Cargo Hooks", "Cargo Liner", "Suggestion 1",
  "Suggestion 2", "Suggestion 3", "Suggestion 4", "Suggestion 5",
  "Suggestion 6", "Suggestion 7", "Suggestion 8", "Suggestion 9",
  "Suggestion 10", "Suggestion 11", "Suggestion 12", "Suggestion 13",
  "Suggestion 14", "Suggestion 15", "Suggestion 16", "Suggestion 17",
  "Suggestion 18", "Suggestion 19", "Suggestion 20", "Suggestion 21",
  "Suggestion 22", "Suggestion 23", "Suggestion 24", "Suggestion 25",
  "Suggestion 26", "Suggestion 27", "Suggestion 28", "Suggestion 29",
  "Suggestion 30" };

public List onAccessorySuggest(FacesContext context,
                               AutoSuggestUIHints hints) {
    ArrayList<SelectItem> suggestItems = new ArrayList<SelectItem>();
    String submittedValue = hints.getSubmittedValue();

    //don't return anything until the user has entered at least 3 characters
    if(hints.getSubmittedValue().length() < 3) {
        return suggestItems;
    }

    for (String s : accessories) {
        if (s.toUpperCase().startsWith(submittedValue.toUpperCase())) {
            suggestItems.add(new SelectItem(s));
        }
    }

    return suggestItems;
}
sernaferna
  • 314
  • 1
  • 6
  • 15

1 Answers1

2

see http://jdevadf.oracle.com/adf-richclient-demo/docs/apidocs/oracle/adf/view/rich/model/AutoSuggestUIHints.html

Actually its is your implementation that should access and consider the max suggest items value passed in. The only use case for which this may work out-of-the-box is if the suggest list is coming from a model driven LOV list in ADF BC

So in summary, you access the max items from AutoSuggestUIHints an dshorten your return list

Frank

  • Thanks Frank. This is definitely true, and one can limit the number of responses that are returned, but what I wasn't able to do is mimic the "More..." functionality that comes with the out-of-the-box BC components. There must be something I can do to the list that's returned to the client, I'm just hoping that when I find it, it's not too hack-ish. :) – sernaferna Jul 12 '12 at 16:06
  • Its not possible to day. The More link you see for the model driven list in ADF BC is not through autosuggest but a smart filter. I'll file an enhancement request to see if there is something we can do on the nehavior tag. – Frank Nimphius-Oracle Jul 19 '12 at 05:53