意図したとおりにコードを実行することができましたが、これが機能する理由の特定の側面がわかりません。Richfaces 3.3.3 で Seam 2.2.2 を実行しています。
xhtml ページのコードは次のとおりです。
...
<h:form id="radiobuttontestform">
<fieldset>
<h:panelGrid columns="3">
<h:selectOneRadio layout="pageDirection" id="myRadio" value="#{actionBean.myRadioButton}">
<f:selectItem itemLabel="First" itemValue="0" />
<f:selectItem itemLabel="Second" itemValue="1" />
<a4j:support event="onclick" ajaxSingle="true" process="myDropdown" reRender="myDropdown,myCount,test" />
</h:selectOneRadio>
<h:panelGrid columns="1" border="0">
<h:selectOneListbox size="1" id="myDropdown" value="#{actionBean.rowCountPredefined}" disabled="#{actionBean.myRadioButton != '0'}">
<f:selectItem itemLabel="10" itemValue="10" />
<f:selectItem itemLabel="20" itemValue="20" />
<f:selectItem itemLabel="30" itemValue="30" />
</h:selectOneListbox>
<h:inputText id="myCount" maxlength="5" value="#{actionBean.rowCountSpecified}" disabled="#{actionBean.myRadioButton != '1'}" required="true">
<f:validateLongRange minimum="1" maximum="1000" />
<rich:ajaxValidator event="onkeyup" for="myCount" />
</h:inputText>
<rich:message id="errorMessage" for="myCount" ajaxRendered="true" showDetail="false" showSummary="true">
<f:facet name="errorMarker">ERROR:</f:facet>
</rich:message>
</h:panelGrid>
</h:panelGrid>
</fieldset>
<h:outputLabel id="test" value="RadioValue: #{actionBean.myRadioButton}" />
<a4j:commandButton id="show" value="Show Values in Log" action="#{actionBean.showValues}" />
<a4j:commandButton id="done" value="Save and end conversation" action="#{actionBean.apply}" />
</h:form>
...
バッキング Bean は、ここに示す 3 つのプロパティのゲッターとセッターを備えた単純な POJO です。(myRadioButton、rowCountPredefined、rowCountSpecified)
これは私が得るものです:(正しい結果)
ラジオボタンの例 http://katzekat.de/Bilder/radio2.png
ラジオ ボタンの例 http://katzekat.de/Bilder/radio.png
ここに私の考えがあります:
ajaxSingle を true に設定すると、ラジオ ボタンのみがサーバーで処理されます。その横のドロップダウンは検証を必要としません - 常に正しい値が含まれています。値をバッキング Bean に永続化するために process="myDropdown" を追加しました。そうしないと、ラジオ ボタンを位置 2 に切り替えると、ドロップダウンが元の値に戻ります。(私はこれが表面的なものにすぎないことを認識しています!) デバッガーでこれを確認したところ、実際にバッキング Bean にプロパティが設定され、すべてが期待どおりに機能しています。
ラジオ ボタンが位置 2 に切り替えられると、値がテキスト ボックスに入力され、検証されます。これは完全に機能し、ラジオ ボタンを位置 1 に戻すと、このフィールドがエラー状態の場合、検証エラーはクリアされます。おそらく、エラー メッセージがリクエスト スコープにのみ存在するためです。
ラジオ ボタンが位置 2 にあるときにデバッガーを再度起動し、テキスト フィールドに有効な値を入力すると、位置 1 に戻ったときにバッキング Bean が更新されないことがわかります。サーバー上で処理するドロップダウン。これは私が理解していないビットですが、テキストフィールドの値はポストバック時に保持されます。(上記の 2 番目のリンクを参照) バッキング Bean にない場合、このテキストフィールドのこの値はどこに保存されますか?