私はFlex + Java(Spring + hibernate)を使用しています...
ジャバ側…
public enum WeekdayType {
MONDAY(Calendar.MONDAY), TUESDAY(Calendar.TUESDAY), WEDNESDAY(
Calendar.WEDNESDAY), THURSDAY(Calendar.THURSDAY), FRIDAY(
Calendar.FRIDAY), SATURDAY(Calendar.SATURDAY), SUNDAY(
Calendar.SUNDAY);
private int day;
private WeekdayType(int day) {
this.day = day;
}
}
私が使用している休止状態のBeanクラス..TimetableVO.java
@Column(name="REPEAT_DAYS")
private String repeatDays;
@Transient
public List<WeekdayType> getRepeatDaysEnumList(){
List<WeekdayType> list = new ArrayList<WeekdayType>();
for(String str : this.repeatDays.split(",")){
list.add(WeekdayType.valueOf(str));
}
return list;
}
@Transient
public void setRepeatDaysEnumList(List<WeekdayType> repeatDays){
StringBuilder sb = new StringBuilder();
for(WeekdayType weekdayType : repeatDays){
sb.append(weekdayType.name());
sb.append(",");
}
this.repeatDays = sb.substring(0, sb.length()-1);
}
そしてFlex側では……
private var timetableVO:TimetableVO = new TimetableVO();
timetableVO.repeatDays = selectedDays.substr(0, selectedDays.length-1);
private var selectedDays:String = null;
protected function selectRepeatedDays(event:MouseEvent):void
{
selectedDays = new String();
if(MON.selected==true)
{
selectedDays += "MONDAY,";
}
if(TUE.selected==true)
{
selectedDays += "TUESDAY,";
}
}
ただ私はrepeatDaysに値を追加していますが、それは与えていますNullPointer Exception
Exception:Property 'repeatDaysEnumList' threw exception; nested exception is java.lang.NullPointerException.......
Caused by: java.lang.NullPointerException
at com.sits.ec.valueObjects.TimetableVO.setRepeatDaysEnumList(TimetableVO.java:64)
私はrepeatDaysEnumListを作成していませんが、セッターとゲッターのためにHibernateが行います。次に、このNull値がどのように来るか...