p : selectedManyManu가 기본 선택을 허용합니까? 나는 이것을 구현할 수 없었다. 나는 심지어 Omnifaces ListConverter와 selectItemsConverter를 성공하지 않고 시도했다. 어떤 도움이나 포인터를 주시면 감사하겠습니다. 페이지가로드 될 때 기본적으로 둘 이상의 항목을 선택할 수 있습니다. 여기에 내 코드 :Primefaces selectManyMenu 기본 선택
POJO :
public class LocationRef implements Serializable{
private integer Seqid;
private String locname;
private String locaddress;
private String phonenumber;
//getters and setters
//tostring
//equals, hashcode
}
백엔드 콩 :
public class SelectionBean implements Serializable {
private List<LocationRef> selectedLocations;
private List<LocationRef> allLocations;
@PostConstruct
public void init() {
selectedLocations = new ArrayList<LocationRef>();
allLocations = new ArrayList<LocationRef>();
selectedLocation = dao.getSelectedLocation(idList);
allLocation = dao.getAllLocations();
}
public List<LocationRef> getSelectedLocations() {
return selectedLocations;
}
public List<LocationRef> getAllLocations() {
return allLocations;
}
public void setAllLocations(List<LocationRef> allLocations) {
this.allLocations = allLocations;
}
}
XHTML :
<p:selectManyMenu id="location" value="#{SelectionBean.selectedLocations}"
converter="omnifaces.SelectItemsConverter"
showCheckbox="true" style="width: 220px"
>
<f:selectItems value="#{SelectionBean.allLocations}" var="loc"
itemValue="#{loc.locationSeqid}"
itemLabel="#{loc.sitename}"/>
</p:selectManyMenu>
그게 전부입니다. selectManyMenu 값을 selectItems ItemValue와 동일한 유형 (컬렉션)으로 설정하면 해결됩니다. 감사. – Tandina
반갑습니다. – BalusC