Question

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;
}
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top