简体   繁体   English

如何正确使用 <h:selectManyCheckbox> 和 <f:selectItems> 符合条件

[英]How to correct use <h:selectManyCheckbox> and <f:selectItems> with Criteria

I'm learning Seam since few days and I want to create simple filter using <h:selectManyCheckbox> and <f:selectItems> tags. 我从几天开始学习Seam,我想使用<h:selectManyCheckbox><f:selectItems>标签创建简单的过滤器。 Here is frag xhtml file with tags: 这是带有标签的frag xhtml文件:

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

In UserSessionSession I have: 在UserSessionSession中,我有:

private List<String> selected; 

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

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

UserSessionPage: 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; 
    }

and in function with criteria restictions: 并与标准限制一起起作用:

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

When I check and submit option nothing happens and console dispalys warning: 当我检查并提交选项时,什么也没有发生,并且控制台显示警告:

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

I don't know how to correct handle this event, can any one help me? 我不知道如何正确处理此事件,有人可以帮助我吗? I will be grateful. 我会很感激。

You will have to change it 您将不得不更改它

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; 
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM