ループでレンダリングされたリンクのリストがあります。リンクをクリックすると、Beanプロパティを設定しますselectedIndex
。Ajaxパラメーターに渡して実行しようとしていますが、完全なフォームが更新されています。それでもnotificationPreferencesBean.retrievePreferences
解雇されていません。このアプローチは正しいですか?
これが私のテンプレートスニペットです:
<ui:repeat value="#{notificationPreferencesBean.userNotificationPreferences}"
var="userNotificationPreferenceVar" varStatus="idx">
<li>
<h:commandLink
value="#{userNotificationPreferenceVar.notificationClassName.label}"
styleClass="#{userNotificationPreferenceVar.cssClassName}"
action="#{notificationPreferencesBean.retrievePreferences}">
<f:ajax execute="@form" render="@none">
<f:param value="#{idx}" name="idx" />
</f:ajax>
</h:commandLink>
</li>
</ui:repeat>
そしてここに豆の宣言があります:
@ManagedProperty(value = "#{param.idx}")
private Integer selectedIndex;
興味深いことに、次のコードはAjaxfullyで機能しますが、を呼び出すだけでnotificationPreferencesBean.retrievePreferences
、selectedIndexを設定しません(パラメーターを渡していないため、予想どおり)
<ui:repeat value="#{notificationPreferencesBean.userNotificationPreferences}"
var="userNotificationPreferenceVar" varStatus="idx">
<li>
<h:commandLink
value="#{userNotificationPreferenceVar.notificationClassName.label}"
styleClass="#{userNotificationPreferenceVar.cssClassName}"
action="#{notificationPreferencesBean.retrievePreferences}">
<f:ajax execute="@form" render="@none" />
</h:commandLink>
</li>
</ui:repeat>
それを行う他の方法はありますか?リンクをクリックしたときにselectedIndexプロパティを設定したいだけです。