0

几天以来我一直在学习 Seam,我想使用 <h:selectManyCheckbox><f:selectItems>标签创建简单的过滤器。这是带有标签的 frag xhtml 文件:

<h:selectManyCheckbox value="#{userSessionsSession.selected}">
    <f:selectItems value="#{usersSessionsPage.logLevelList}" />
</h:selectManyCheckbox>

在 UserSessionSession 我有:

private List<String> selected; 

    public List<String> getSelected() {
        return selected;
    }

    public void setSelected(List<String> selected) {
        this.selected = selected;
    }

用户会话页面:

private List<SelectItem> logLevelList;

public List<SelectItem> getLogLevelList(){
        if(logLevelList == null){
            logLevelList = new ArrayList<SelectItem>();
            Collection<MdoUserSessionDetStatus> tmpList = sessionAuditUtils.getDetailsStatusEntities();
            for(MdoUserSessionDetStatus mdo: tmpList){
                logLevelList.add(new SelectItem(mdo.getCode(), mdo.getName()));
            }
        }
        return logLevelList; 
    }

并在具有标准限制的功能中:

if (selected != null && !ANY_STATUS.equals(selected)) {
            criteria.add(Restrictions.eq("mdoUserSessionDetStatus.code", selected));
        }

当我检查并提交选项时,没有任何反应并且控制台显示警告:

 WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=filterPanelForm:j_id163[severity=(ERROR 2), summary=(Conversion Error setting value 'DEBUG' for '#{userSessionsSession.selected}'. ), detail=(Conversion Error setting value 'DEBUG' for '#{userSessionsSession.selected}'. )]

我不知道如何正确处理此事件,任何人都可以帮助我吗?我会很感激。

4

1 回答 1

0

你将不得不改变它

private SelectItem[] logLevelList;

public SelectItem[] getLogLevelList(){

if(logLevelList == null){

Collection<MdoUserSessionDetStatus> tmpList =   sessionAuditUtils.
                                                    getDetailsStatusEntities(); 

logLevelList =  new SelectItem[tmpList .size() + 1];

for(MdoUserSessionDetStatus mdo: tmpList){
            logLevelList.add(new SelectItem(mdo.getCode(), mdo.getName()));
         }
     }
     return logLevelList; 
 }
于 2012-09-13T11:28:49.673 回答