2014-04-15 10 views
0

List를 반복하여 각 요소에 체크 박스를 만들고 싶습니다. 내가 가지고있는 코드는 다음과 같습니다JSF h : selectItem inside ui : repeat - 작동하지 않습니다.

<h:outputText value="Choose" /> 
<p:selectManyCheckbox value="#{filterTypeBean.selectedFilterTypes}"> 
    <ui:repeat var="checkbox" value="#{filterTypeBean.listFilterTypes()}" 
     varStatus="status"> 
     <!-- <h:outputText value="#{checkbox.filterTypeName}" /> --> 
     <f:selectItem itemLabel="#{checkbox.filterTypeName}" 
      itemValue="#{checkbox}" /> 
    </ui:repeat> 
</p:selectManyCheckbox> 

내 빈 클래스에는 다음이 포함

private List<FilterType> selectedFilterTypes; 

public List<TFilterType> getSelectedFilterTypes() { 
     return selectedFilterTypes; 
} 

public void setSelectedFilterTypes(List<TFilterType> selectedFilterTypes) { 
    this.selectedFilterTypes = selectedFilterTypes; 
} 

public List<FilterType> listFilterTypes() { 
     EntityManager em = HibernateUtil.getEntityManager(); 
     Query q = em.createQuery("select u from FilterType u"); 
     List<FilterType> filterList = q.getResultList(); 
     for (FilterType filterType : filterList) { 
      System.out.println(filterType.getFilterTypeName()); 
     } 
     return filterList; 
    } 

I하지 예상 된 결과 있어요 - 더 체크 박스는 filterList (I 화면에 아무것도)에 표시되지 않습니다. 필터 유형 -> 의 이름을 인쇄 할 줄의 주석을 제거하면 이름이 있습니다. 제발,이 문제를 해결하도록 도와주세요.

+1

'F : 그 목적 selectItems'. –

답변

2

당신은 대신 f:selectItems를 사용

<f:selectItems var="checkbox" value="#{filterTypeBean.listFilterTypes()}" itemLabel="#{checkbox.filterTypeName}" itemValue="#{checkbox}" /> 

처럼 무언가에 의해

<ui:repeat var="checkbox" value="#{filterTypeBean.listFilterTypes()}" 
    varStatus="status"> 
    <!-- <h:outputText value="#{checkbox.filterTypeName}" /> --> 
    <f:selectItem itemLabel="#{checkbox.filterTypeName}" 
     itemValue="#{checkbox}" /> 
</ui:repeat> 

을 대체하지만 난 당신의 itemValue="#{checkbox}"이 전체 개체를 포함하는 설명도 있기 때문에 작동합니다 생각하지 않는다한다.

상세 정보 :