我正在尝试使用rich:suggestionbox
。我浏览了Richfaces提供的教程。重要的是我使用的是Richfaces 3.1.4 JAR。在建议框中,我只是尝试在开始时填充一些默认数据,但建议框根本没有渲染。当我尝试在Firefox中查看错误控制台时,会显示以下错误消息:
Error: this.element is null
Source File: http://localhost:9080/sample/a4j_3_1_4.GAorg/richfaces/renderkit/html/scripts/suggestionbox.js.faces
Line: 2
JSF CODE
<a4j:region selfRendered="true" id="region1">
<h:inputText id="fx" />
<rich:suggestionbox width="50" height="50" for="fx" nothingLabel="HI"
suggestionAction="#{basic.inputData}" fetchValue="#{basic.selectedData}"
var="result" id="suggestion">
<h:column>
<h:outputText value="#{result.value}" />
</h:column>
</rich:suggestionbox>
<h:commandButton id="submit" value="show data"
action="#{basic.submit}"></h:commandButton>
</a4j:region>
MANAGED BEAN
enter code here
private List<SelectedList> inputData; // Setter
private String selectedData; // Getter and Setter
public List<SelectedList> getInputData() { //Getter
if(inputData!=null){
inputData = new ArrayList<SelectedList>();
inputData.add(new SelectedList("1","equal"));
inputData.add(new SelectedList("2","not equal"));
inputData.add(new SelectedList("3","greater"));
inputData.add(new SelectedList("4","lesser"));
}
return inputData;
}
如果你愿意,请帮助。
答案 0 :(得分:0)
已编辑:更改代码后:
更改方法inputData
,如下所示:
(当然,我相信您需要根据建议字符串调整inputdata。)
public List<Capital> inputData(Object suggest) {
String pref = (String)suggest;
//if (suggest...) - add this! to complete according the word
ArrayList<SelectedList> inputData = new ArrayList<SelectedList>();
inputData.add(new SelectedList("1","equal"));
inputData.add(new SelectedList("2","not equal"));
inputData.add(new SelectedList("3","greater"));
inputData.add(new SelectedList("4","lesser"));
return inputData;
}
和for:
fetchValue="#{basic.selectedData}"
您需要将其更改为:fetchValue="#{result.value}"
其中,值为SelectedList
中的getter方法。
如果您遗失它,它将不会显示..
的示例