2番目の質問の場合:それについてはわかりません。[BalusCに質問し
てください;)]最初の質問の場合:
はい、テキストボックスBおよびCの値を取得できます。これを行うには、これらの値をテキストの属性として渡す必要があります。ボックスA。次の例を参照してください。テキストボックスAには2つの属性が導入されており、他のテキストボックスの値がそれらの属性の値として割り当てられています。
<h:form>
<h:inputText id="txtA">
<f:validator validatorId="textValidator"/>
<f:attribute name="attrib_textB" value="#{myBean.textB}"/>
<f:attribute name="attrib_textC" value="#{myBean.textC}"/>
</h:inputText>
<h:inputText value="#{myBean.textB}">
<a4j:support event="onchange"/>
</h:inputText>
<h:inputText value="#{myBean.textC}">
<a4j:support event="onchange"/>
</h:inputText>
<a4j:commandButton value="Save"/>
</h:form>
これで、バリデータークラスで、このような変数にアクセスできます。
public void validate(FacesContext arg0, UIComponent arg1, Object arg2) throws ValidatorException {
String textA = (String) arg2;//value of text box A
String textB = (String) arg1.getAttributes().get("attrib_textB");//value of text box B
String textC = (String) arg1.getAttributes().get("attrib_textC");//value of text box C
}
それで全部です。私の「MyBean」クラスには、textAおよびtextB文字列フィールド用のgetterメソッドとsetterメソッドがあることに注意してください。