2017-08-16 113 views
0

嗨,我有以下snipples:selectOneMenu用于不显示值

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> 

我得到的值当我打印出用户列表时最新的可能的时候,也就是说,它们是过去之前的HTML是:

[[email protected], [email protected], [email protected], [email protected], [email protected]] 

这对我来说看起来不错,但我总是得到以下信息

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. 

菜单是HTML页面上显示的却是空。

任何想法,为什么这是这种情况?

感谢您的帮助。

海盗

+0

您在哪里打印清单?我没有看到代码。 是因为SimController对于userList没有getter? – vvtx

+0

它说上面的SimController中的getUserList ...我错过了什么吗? – Viking

+1

Getters不采取方法论据。你有一个'public List getUserList(String Id)',但你应该有一个'public List getUserList()'方法。 – BalusC

回答

0

正如@balusc已经指出的那样,尝试<f:selectItems value="#{SimController.getUserList(id)}"从facelet里,如果你可以访问id,这是我的猜测是#{pSimController.details.Id}

0

既然不能从评论关闭问题...这里是信贷@BalusC

吸气剂不采取方法的参数。你有一个公共列表getUserList(String Id),但你应该有一个公共List getUserList()方法。 - BalusC 7分钟前

感谢您的帮助

相关问题