3

p:selectedManyManu はデフォルトの選択を許可しますか? 私はこれを実装することができませんでした。Omnifaces ListConverter と selectItemsConverter を試しても成功しませんでした。ヘルプやポインタをいただければ幸いです。ページの読み込み時に、デフォルトで複数の項目が選択される可能性があります。ここに私のコードがあります:

ポジョ:

public class LocationRef implements Serializable{
private integer Seqid;
private String locname;
private String locaddress;
private String phonenumber;

//getters and setters
//tostring
//equals, hashcode

}

バックエンド Bean:

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>
4

1 に答える 1

2

あなた<f:selectItems itemValue>は正しくありません。コレクションの背後に個別に設定するのと同じ値を表す必要があります<p:selectManyMenu value>

これはそれを行う必要があります:

itemValue="#{loc}"

omnifaces.SelectItemsConverter、目的に適したコンバータです。は、子として使用せず、代わりに「プレーン」を独自の属性としてomnifaces.ListConverter使用するコンポーネントのみを対象としています (および など) 。<f:selectItem(s)>List<p:autoComplete><p:pickList>

于 2013-07-19T20:32:48.080 に答える