私は次のJSFフォームを持っています:
...
<p:column>
<h:outputText value="Image Id:" style="font-weight:bold; padding-right:10px" />
</p:column>
<p:column>
<h:outputText value="#{syncCenterBean.selectedCRImageData.imId}" />
</p:column>
</p:row>
....
<p:row>
<p:column>
<h:outputText value="Image Type" style="font-weight:bold; padding-right:10px" />
</p:column>
<p:column>
<p:selectOneMenu id="imtype" value="#{syncCenterBean.cRImageType}" converter="#{imageTypeConvert}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{syncCenterBean.cRImageTypeList}" var="cRImageType" itemValue="#{cRImageType.imTypeId}" itemLabel="#{cRImageType.imTypeName}" />
</p:selectOneMenu>
</p:column>
</p:row>
...
これらはすべて、データ テーブルの行が選択されたときに読み込まれるダイアログ ボックスにあります。次のように関連する 2 つの Hibernate エンティティがあります。
CRImageData
@Entity
@Table(name = "imageviewer_crimagedata")
public class CRImageData implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
@Column(name = "ImId")
private Long imId;
@Column(name = "ImName")
private String imName;
@Column(name = "ImTypeId")
private Long imTypeId;
@Column(name = "ImPatientId")
private String imPatientId;
@Column(name = "ImStatus")
private String imStatus;
@Column(name = "imFormat")
private String imFormat;
@ManyToOne
@JoinColumn(name="ImTypeId",insertable=false,updatable=false)
private CRImageType cRImageType;
および CRImageType
@Entity
@Table(name = "imageviewer_crimagetype")
public class CRImageType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
@Column(name = "ImTypeId")
private Long imTypeId;
@Column(name = "ImTypeName")
private String imTypeName;
@Column(name = "ImTypeDescription")
private String imTypeDescription;
@ManyToMany(cascade = {CascadeType.ALL})
@JoinTable(name="imageviewer_imtype_variable",
joinColumns={@JoinColumn(name="ImTypeId")},
inverseJoinColumns={@JoinColumn(name="VarId")})
private Set<CRVariable> crvariables = new HashSet<CRVariable>();
@OneToMany(mappedBy="cRImageType")
private Set<CRImageData> cRImageData;
selectOneMenu には次の Converter を使用します。
@ViewScoped
@ManagedBean(name = "imageTypeConvert")
@FacesConverter(forClass=CRImageType.class,value="imageTypeConvert")
public class ImageTypeConvert implements Converter {
@ManagedProperty(value="#{syncCenterBean}")
private SyncCenterBean syncCenterBean;
FacesContext context = FacesContext.getCurrentInstance();
SyncCenterBean mybean = (SyncCenterBean) context.getExternalContext().getSessionMap().get("syncCenterBean");
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value{
Long imTypeId = Long.parseLong(value.trim());
List<CRImageType> cRImageTypeList = mybean.getcRImageTypeList();
for (CRImageType cRImageType:cRImageTypeList) {
if(cRImageType.getImTypeId().compareTo(imTypeId)==0){
return cRImageType;
}
}
return null;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
System.out.println("!!!!!! (2) Into getAsString");
return Long.toString(((CRImageType) value).getImTypeId());
}
public SyncCenterBean getSyncCenterBean() {
return syncCenterBean;
}
public void setSyncCenterBean(SyncCenterBean syncCenterBean) {
this.syncCenterBean = syncCenterBean;
}
}
そして最後に私のBackBean:
@ManagedBean(name = "syncCenterBean")
@ViewScoped
public class SyncCenterBean implements Serializable {
@PostConstruct
public void init(){
cRImageTypeList = getImageTypesDB();
cRImageType = new CRImageType();
cRImageDataList = populateImageOnlyToDataWarehouseList(getImageDataSOAP());
cRImageDataListLocal = getImageDataDB();
}
...
しかし、データタブを読み込もうとすると、次のエラーが発生します。
javax.portlet.faces.BridgeException: javax.faces.FacesException: com.forth.actions.ImageTypeConvert
at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:98)
at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:99)
...
Caused by: java.io.NotSerializableException: com.forth.actions.ImageTypeConvert
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at java.util.HashMap.writeObject(HashMap.java:1001)
私が間違ってやっているアイデアはありますか?