tags:

views:

89

answers:

1

Hi,

I'm trying use rich:suggestionbox. I went through the tutorial provided by the Richfaces. important think is i am using richface 3.1.4 JAR. In the suggestion box i am just trying to populate some default data's at the starting, but the suggestion box is not rendering at all. When i try to see the error console in firefox the following error message is shown

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;
}

kindly help.

A: 

EDITED:after changing your code:

change the method inputData like this:

(Of course, I believe that you need to adjust the inputdata according the the suggest string..)

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;
    }

and for:

fetchValue="#{basic.selectedData}"

You need to change it to: fetchValue="#{result.value}" where value is has a getter method in SelectedList.

If you are missing it, it will not be displayed..

See an example of Suggestion Box Demo

Odelya
Sorry it was a typo error instead of inputData i ha typed as populate in the JSF code. I have the getter and the setter method generated by default, thats the reason i have mentioned Getter and Setter in the Code itself to reduce the space.
Hari
In suggestionAction you need an action to fill the selected item.You don't need getter and setter for it.
Odelya
I edited my answer now.
Odelya