I am trying to populate a SelectInputText (auto-complete) field for when a user edits a record. The SelectInputText works fine however I need the current value to be displayed when a user goes in to edit the record.
I have followed the advice from this thread: http://www.icefaces.org/JForum/posts/list/3718.page
But get a NullPointer as my method can't find the JSF component.
My JSF page has a form (<h:form id="scheduleDate">) and in that form is the SelectInputText component (<ice:selectInputText id="unlocode"...)
My code to populate this component is:
//Set the list of matches to the incoming value selectList.add(new SelectItem(scheduleDate.getUnLocode(), scheduleDate.getUnLocode().getName())); //Find the JSF component from the page SelectInputText sit = (SelectInputText)FacesContext.getCurrentInstance().getViewRoot().findComponent("scheduleDate:unlocode"); //Set the selected item on the component (this is where the null pointer occurs sit.setSelectedItem(scheduleDate.getUnLocode().getLocode()); sit.setValue(scheduleDate.getUnLocode());
I should mention that I'm calling this method from a page action eg:
<page no-conversation-view-id="/ScheduleDateList.xhtml" action="#{autoCompleteUNLocode.loadIntoSelectList}"...