Hi I have the following snipples:
SimController:
private static List<SelectItem> userList;
public List<SelectItem> getUserList(String Id) {
try {
userList = new ArrayList<SelectItem>();
userList = PDAO.getUserList(Id);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return userList;
}
public void setUserList(List<SelectItem> userlist){
this.userlist = userlist;
}
PDAO:
public static List<SelectItem> getUserList(String Id) throws ClassNotFoundException, SQLException {
String sqlCmdName = "sql_get_other_users";
String sql = getSql(sqlCmdName);
sql = Util.prepareSqlExt(sql, new String[] { Id });
return (List<SelectItem>) buildResultSet(new ConverterToUserList(), sqlCmdName, sql);
}
class ConverterToUserList implements ResultSetConverterInterface {
public Object convertResultSet(ResultSet resultSet) throws SQLException {
List<SelectItem> userList = new ArrayList<SelectItem>();
while (resultSet.next()) {
userList.add(new SelectItem(resultSet.getString(1)));
}
if (userList.isEmpty())
return null;
return userList;
}
}
Html:
<t:div styleClass="#{SimController.simTabName=='SIMULATION_USERS'?'tabPaneActive':'tabPane'}">
<h:commandButton style="width: 120px !important;" id="TabId3" value="#{messages.tab_other_user}" action="#{SimController.goOtherUsers}" immediate="true" onclick="wait2();">
<f:param name="id" value="#{pSimController.details.Id}" />
</h:commandButton>
</t:div>
<h:selectOneMenu styleClass="linkButtons" value="SimController.userListtry" onchange="document.getElementById('SimFormId:mdsTabId3').click();">
<f:selectItem itemValue="" itemLabel="-" />
<f:selectItems value="#{SimController.userList}" />
</h:selectOneMenu>
The values I get when I print out the userlist at the latest possible moment i.e. before they are past the the html is:
[javax.faces.model.SelectItem@13a89211, javax.faces.model.SelectItem@46c92ce7, javax.faces.model.SelectItem@7dbe8fcb, javax.faces.model.SelectItem@4a3d1f6a, javax.faces.model.SelectItem@1d522426]
which to me looks fine but I always get the following message
org.apache.myfaces.shared.util.SelectItemsIterator hasNext
WARNING: ValueExpression #{SimController.userList} of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/pSim.xhtml][Class: org.apache.myfaces.custom.document.Document,Id: appId][Class: org.apache.myfaces.custom.document.DocumentBody,Id: appBodyId][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id_t][Class: javax.faces.component.html.HtmlPanelGroup,Id: j_id_1u][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id_1v][Class: javax.faces.component.html.HtmlPanelGroup,Id: j_id_1z][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id_20][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: j_id_28][Class: javax.faces.component.UISelectItems,Id: j_id_2a]} does not reference an Object of type SelectItem, array, Iterable or Map, but of type: null
org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase renderChildren
WARNING: PanelGrid {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/pSim.xhtml][Class: org.apache.myfaces.custom.document.Document,Id: appId][Class: org.apache.myfaces.custom.document.DocumentBody,Id: appBodyId][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id_t][Class: javax.faces.component.html.HtmlPanelGroup,Id: j_id_1u][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id_1v][Class: javax.faces.component.html.HtmlPanelGroup,Id: j_id_1z][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id_20] Location: /pages/planung/inc/buttonStripBottomSimul.xhtml at line 3 and column 55} has not enough children. Child count should be a multiple of the columns attribute.
The menu is shown on the html page but it is empty.
Any idea on why this is the case??
Thanks for all your help.
Viking