Skip to content

Instantly share code, notes, and snippets.

@A-pZ
Created April 23, 2013 09:36
Show Gist options
  • Save A-pZ/5442184 to your computer and use it in GitHub Desktop.
Save A-pZ/5442184 to your computer and use it in GitHub Desktop.
Struts2とTypeConvertionで、以下の場合に変換されないでデフォルトが使われてしまう
Element_birthday=lumi2.type.CalendarConverter
@Validations(requiredStrings = {
@RequiredStringValidator(fieldName = "username", message = "ユーザー名は必須入力です"),
}, intRangeFields = {
@IntRangeFieldValidator(fieldName = "age", min = "20", max = "99", message = "年齢は20~99の値で入力してください")
}, regexFields = {
@RegexFieldValidator(fieldName = "telephone", regex = "\\d{2,5}-\\d{1,4}-\\d{4,5}", message = "電話番号のフォーマットが正しくありません"),
})
public @Data
class SampleValueObject implements Serializable {
private static final long serialVersionUID = 8751205553661194912L;
private String username;
private int age;
private String telephone;
@Element(value = java.util.Calendar.class)
private List<Calendar> birthday;
}
Setting params struts.validateOnly => [ true ] param.telephone => [ ] param.age => [ 22 ] param.username => [ ] param.birthday[1] => [ 2012/PP/13 ] param.birthday[0] => [ 2015/5/5 ] struts.enableJSONValidation => [ true ]
.......
2013-04-23 18:33:02,274 DEBUG [com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler] - Entering nullPropertyValue [target=SampleValueObject(username=null, age=22, telephone=null, birthday=null), property=birthday]
2013-04-23 18:33:02,274 DEBUG [com.opensymphony.xwork2.conversion.impl.XWorkConverter] - Retrieving convert for class [class lumi2.vo.SampleValueObject] and property [param.birthday.null]
2013-04-23 18:33:02,274 DEBUG [com.opensymphony.xwork2.conversion.impl.XWorkConverter] - Converter is null for property [param.birthday.null]. Mapping size [1]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment