我编写了一个简单的概念验证应用程序来使用Oracle ADF测试自动完成字段,虽然它主要起作用,maxSuggestedItems
属性似乎没有任何影响。 Oracle的文档表明,放置一个非-1的值应该限制返回的值列表,并在底部包含一个“More ...”项,这将导致返回整个列表。相反,始终返回整个列表。
这是我必须手动实现的吗?如果是这样,那会怎么做呢?
JSFF页面中包含以下代码:
<af:inputText label="Accessories:" id="it4">
<af:autoSuggestBehavior suggestItems="#{accessorySuggest.onAccessorySuggest}"
maxSuggestedItems="5"/>
</af:inputText>
返回建议值的方法(当然所有硬编码)如下:
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;
}
答案 0 :(得分:2)
实际上它是你的实现应该访问并考虑传入的最大建议项值。唯一可以开箱即用的用例是建议列表来自模型驱动的LOV列表在ADF BC
总而言之,您可以从AutoSuggestUIHints访问最大项目,并获取返回列表
谢