15. G*Magazine vol.1
ErrorMessagePanel にモデルの errors をバインディングする事で セージが表示されます。
エラー情報をビューで通知する事が可能になります。
■エラーメッセージの追加
griffon-app/i18n/messages.properties にエラーメッセージを追
加します。今回は Validation プラグインのドキュメントページの
エラーメッセージをそのまま追加します。
default.matches.message=Property [{0}] of class [{1}] with value [{2}]
does not match the required pattern [{3}]
まとめ
default.url.message=Property [{0}] of class [{1}] with value [{2}] is
not a valid URL
default.creditCard.message=Property [{0}] of class [{1}] with value 今回は Griffon でよく使うバインディングを紹介しました。バ
[{2}] is not a valid credit card number インディングを理解する事で MVC 間での情報のやりとりも、よ
default.email.message=Property [{0}] of class [{1}] with value [{2}] りスマートな形で実装する事ができるようになります。次回はス
is not a valid e-mail address レッドについて紹介したいと思います。それではまた、お会いし
default.range.message=Property [{0}] of class [{1}] with value [{2}] ましょう。
does not fall within the valid range
default.size.message=Property [{0}] of class [{1}] with value [{2}]
does not fall within the valid size
default.max.message=Property [{0}] of class [{1}] with value [{2}]
exceeds maximum value [{3}]
default.min.message=Property [{0}] of class [{1}] with value [{2}] is
less than minimum value [{3}]
default.maxSize.message=Property [{0}] of class [{1}] with value [{2}]
exceeds the maximum size of [{3}]
default.minSize.message=Property [{0}] of class [{1}] with value [{2}]
is less than the minimum size of [{3}]
default.validator.message=Property [{0}] of class [{1}] with value
[{2}] does not pass custom validation
default.inList.message=Property [{0}] of class [{1}] with value [{2}]
is not contained within the list [{3}]
default.blank.message=Property [{0}] of class [{1}] cannot be blank
default.notEqual.message=Property [{0}] of class [{1}] with value [{2}]
cannot equal [{3}]
default.nullable.message=Property [{0}] of class [{1}] cannot be null
■アプリケーションの実行
それではアプリケーションを実行してみましょう。
griffon run-app
実行すると以下のようになります。
ボタンをクリックしてエラーがあると以下のようにエラーメッ
Griffon 不定期便 〜第 2 回 バインディング編〜 15