如何正确使用<h:selectmanycheckbox>和<f:selectitems> with Criteria </f:selectitems> </h:selectmanycheckbox>

时间:2012-09-13 08:39:33

标签: java jsf seam criteria

我正在学习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;
    }

UserSessionPage:

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}'. )]

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

1 个答案:

答案 0 :(得分: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; 
 }