私のボタンのonSubmitメソッドを使用してCheckBoxMulitpleChoiceコンポーネントのいずれかを更新するには、ウィジェットパネルで少なくとも2回のクリックが必要です。これらのコンポーネントを最初のクリックで更新するにはどうすればよいですか?Wicket CheckBoxMultipleChoiceが更新されない
2つのCheckBoxMultipleChoiceコンポーネントを使用して、通知するユーザーのリストをコンパイルしています。最初のものは、DropDownChoiceチーム選択で利用可能なユーザーに基づいて作成されます。ユーザーはそのチームのユーザーを選択して、2番目のCheckBoxMultipleChoiceに追加することができます。これは、通知するすべてのユーザーを表示し、ユーザーがユーザーを削除できるようにします。
私はパレットコンポーネントを使用しようとしましたが、Wicket 1.3.1(これは1.4への移行に問題がありますが、これは別の投稿用です)を使用していて、UIを制御できませんでした。私もフォームにコンポーネントを配置しようとしましたが、これは機能を変更していません。チェックボックスからエントリを追加または削除するには、少なくとも2回のクリックが必要です。 getValue()は、ボタンの動作が実行されるまで更新されないようです。
// Team selection for notification =================================
final DropDownChoice teamNotificationChoice = new DropDownChoice("teamNotification", teamList, new IChoiceRenderer() {
public Object getDisplayValue(Object o) {
return ((Team) o).getName();
}
public String getIdValue(Object o, int i) {
return Long.toString(((Team) o).getId());
}
});
notifySelectionList.add(teamNotificationChoice);
// teamUser selection list for notification ========================
List<ItemUser> choices = UserUtils.convertToItemUserListFromUsers(getJtrac().findUsersForSpace(space.getId()));
teamUsers = new CheckBoxMultipleChoice("teamUsers", choices, new IChoiceRenderer() {
public Object getDisplayValue(Object o) {
return ((ItemUser) o).getUser().getName();
}
public String getIdValue(Object o, int i) {
return ((ItemUser) o).getUser().getLoginName();
}
});
notifySelectionList.add(teamUsers);
// Add selected teamUsers button ===================================
Button button = new Button("addUsersToList") {
@Override
public void onSubmit(){
}
};
button.add(new AjaxFormComponentUpdatingBehavior("onClick") {
protected void onUpdate(AjaxRequestTarget target) {
List choices = teamUsers.getChoices();
String value = teamUsers.getValue();
for (int index = 0; index < choices.size(); index++) {
final ItemUser choice = (ItemUser) choices.get(index);
if(isSelected(choice, index, value)&!userSelection.contains(choice)) {
userSelection.add(choice);
}
}
SortUtils.sortItemUsers(userSelection);
itemUsers.setChoices(userSelection);
target.addComponent(itemUsers);
}
});
notifySelectionList.add(button);
notifySelectionList.setOutputMarkupId(true);
// notify list ===================================================
itemUsers = new CheckBoxMultipleChoice("itemUsers", userSelection, new IChoiceRenderer() {
public Object getDisplayValue(Object o) {
return ((ItemUser) o).getUser().getName();
}
public String getIdValue(Object o, int i) {
return ((ItemUser) o).getUser().getLoginName();
}
});
itemUsers.setMaxRows(10);
itemUsers.setOutputMarkupId(true);
notifyList.setOutputMarkupId(true);
notifyList.add(itemUsers);
// Remove selected teamUsers button ===================================
Button removeButton = new Button("removeUsersFromList") {
@Override
public void onSubmit(){
}
};
removeButton.add(new AjaxFormComponentUpdatingBehavior("onClick") {
protected void onUpdate(AjaxRequestTarget target) {
List choices = itemUsers.getChoices();
String value = itemUsers.getValue();
for (int index = 0; index < choices.size(); index++) {
final ItemUser choice = (ItemUser) choices.get(index);
if(isSelected(choice, index, value)) {
userSelection.remove(choice);
}
}
itemUsers.setChoices(userSelection);
target.addComponent(itemUsers);
}
});
notifyList.add(removeButton);
誰もが気にならば、私は、私はこれがないと仮定任意のフィードバックを取得していないので、[OK]を、私は、知らない...あなたが提供することができるかもしれどんなアドバイスを事前に
新しいものにアップグレードしてください。 1.3.1は非常に古いバージョンです。 –
@ martin-gあなたは私の投稿を読んだことがありますか?問題はバージョンに関連していません。それはAjaxFormComponentUpdatingBehavior()の過度の使用で終わった。 – OnesAndZeros