2つ目は、S2AnywhereValidator についてです。
Dtoのスコープが session のときに S2AnywhereValidator を継承した Validator が
正しく動作しないようです。
s2jsf-exampleに含まれるAnywareCalenderValidatorを使った再現サンプルを作成しました。
添付のファイルに、s2-jsf-example-1.1.2.zipに含まれているjarをコピーしてください。
再現手順は、
1) page1.html で正常な値を入力し、nextボタンで次ページへ移る
2) page2.html から prevボタンで戻る
3) page1.html で不正な値を入力し、 nextボタンを押す
3のときにバリデーションエラーが出るはずだが、
このケースではバリデーションエラーとならずに次ページへ行ってしまう。
これを回避するために、S2AnywhereValidatorのvalidateメソッドを次のように書き換えました。
public void validate(FacesContext context, UIComponent component,
Object value) throws ValidatorException {
if (value == null)
{ return; } UIComponent[] targetComponents = getTargetComponents(component);
Object[] targetValues = new Object[targetComponents.length];
for (int i = 0; i < targetComponents.length; i++) {
targetValues[i] = null;
if (targetComponents[i] instanceof UIInput)
if (targetValues[i] == null)
{ targetValues[i] = ValueHolderUtil.getValue(targetComponents[i]); } }
doValidate(context, component, value, targetComponents, targetValues); }
再現サンプル含めたexamples.jsf.validator.TestAnywareValidatorというクラスで
試してみましたが、意図したとおりに動いているように見えます。
対応方法としてあっていますでしょうか?