日々精進

新しく学んだことを書き留めていきます

JSFのValidatorにControllerから値を渡す

f:attribute経由で渡せる。以下のようにxhtmlを書くと、

<h:inputText>
    <f:validator validatorId="validateEmail" />
    <f:attribute name="foo" value="#{controller.foo}" />
</h:inputText>

Validatorのvalidateメソッドで以下のようにして値を受け取れる。

String foo = component.getAttributes().get("foo");

参考: