動作中: sourceValueとtargetvalueが文字列のリストである場合、これは私の動作中のrich:listShuttleです。
1.JSFページ
<rich:listShuttle id="companyJurisdictionShutle"
sourceValue="#{companyAdminAction.statesList}"
targetValue="#{companyAdminAction.selectedStates}"
var="item" orderControlsVisible="false" fastOrderControlsVisible="false"
sourceCaptionLabel="Available"
targetCaptionLabel="Selected" styleClass="lishShuttle">
<rich:column>
#{item}
</rich:column>
</rich:listShuttle>
2.バッキングビーン
//sourceValue
public List<String> getStatesList() {
for (DMPJurisdiction dmpJurisdiction: jurisdictionList) {
if(!statesList.contains(dmpJurisdiction.getJurisName())) {
statesList.add(dmpJurisdiction.getJurisName());
}
}
return statesList;
}
//targetValue
public List<String> getSelectedStates() {
return selectedStates;
}
3.値オブジェクト
public class DMPJurisdiction implements Serializable {
/** serial version UID **/
private final static Long serialVersionUID = 109892748283726L;
/** jurisdiction id **/
private Long jurisId;
/** name **/
private String jurisName;
/** description **/
private String jurisDescription;
/** code **/
private String jurisCode;
//Getters and Setters
}
動作しない:リストシャトルを変更して、sourceValueとtargetValueが以前のように文字列のリストではなく、複雑なオブジェクト(DMPJurisdiction)のリストになるようにしました。そのために私はコンバーターを書きました。
1.JSFページ
<rich:listShuttle id="companyJurisdictionShutle"
sourceValue="#{companyAdminAction.jurisdictionList}"
targetValue="#{companyAdminAction.targetJurisdictionList}"
converter="#{dmpJurisdictionConverter}"
var="item" orderControlsVisible="false" fastOrderControlsVisible="false"
sourceCaptionLabel="Available"
targetCaptionLabel="Selected" styleClass="lishShuttle">
<rich:column>
#{item.jurisName}
</rich:column>
</rich:listShuttle>
2.バッキングビーン:上記の複雑なオブジェクトDMPJurisdictionのリストを返します。
//sourceValue
public List<DMPJurisdiction> getJurisdictionList() {
return jurisdictionList;
}
//targetValue
public List<DMPJurisdiction> getTargetJurisdictionList() {
return targetJurisdictionList;
}
3.コンバーター
public class DmpJurisdictionConverter implements javax.faces.convert.Converter {
public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String s) {
List<DMPJurisdiction> dmpJurisdictionList = Cache.loadAllDmpJurisdictions();
for (DMPJurisdiction dmpJurisdiction : dmpJurisdictionList) {
if (dmpJurisdiction.getJurisName().equals(s)) {
return dmpJurisdiction;
}
}
return null;
}
public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object o) {
List<DMPJurisdiction> dmpJurisdictionList = Cache.loadAllDmpJurisdictions();
for (DMPJurisdiction dmpJurisdiction : dmpJurisdictionList) {
if (((DMPJurisdiction) o).getJurisName().equals(dmpJurisdiction.getJurisName())) {
return dmpJurisdiction.getJurisName();
}
}
return null;
}
}
4.エラー: sourceId=accountWorkcaseOpenTabForm:addDmpCompanySubview:companyJurisdictionShutle[severity=(ERROR 2), summary=(javax.el.PropertyNotFoundException: /html/workcase/type/dmp/admin/AddCompany.xhtml @55,98 sourceValue="#{companyAdminAction.jurisdictionList}": Property 'jurisdictionList' not writable on type java.util.List), detail=(javax.el.PropertyNotFoundException: /html/workcase/type/dmp/admin/AddCompany.xhtml @55,98 sourceValue="#{companyAdminAction.jurisdictionList}": Property 'jurisdictionList' not writable on type java.util.List)] ||||
注:補足として、以下の別の無関係なJSFページに示すように、selectOneMenuに同じdmpJurisdictionConverterを正常に使用しています。
<h:selectOneMenu value="#{companyAdminAction.dmpJurisdiction}" converter="#{dmpJurisdictionConverter}">
<s:selectItems var="item" value="#{companyAdminAction.jurisdictionList}" label="#{item.jurisName}"
hideNoSelectionLabel="true" noSelectionLabel="-- Select Jurisdiction --"/>
<a4j:support event="onchange" action="#{companyAdminAction.loadCompanyList()}"
reRender="dmpCompanies"/>
</h:selectOneMenu>