皆さん、こんにちは、改札プロジェクトに問題があるようです。
基本的に、クリックするとLoadable Detatcheable Modelを更新し、更新されたモデルの結果でリストビューを再レンダリングするAjaxLinkがあります
ここに私のコードがあります
package com.blackwell.wicket.manager;
public class ManageExercise extends BaseManagerPage {
private static final long serialVersionUID = -3241765837700606142L;
private ModalWindow mwAddExercise;
private Integer searchId;
private String name;
private String complexity;
private LoadableDetachableModel<List<Exercise>> modelList;
@SpringBean
ExerciseJdbc exerciseJdbc;
public ManageExercise() {
add(mwAddExercise = new ModalWindow("mwAddExercise"));
final WebMarkupContainer wmc = new WebMarkupContainer("wmc");
wmc.setOutputMarkupId(true);
modelList = exerciseModel(searchId, name, complexity);
Form<String> searchForm = new Form<String>("searchForm");
searchForm.add(new TextField<Integer>("searchId",
new PropertyModel<Integer>(this, "searchId")));
searchForm.add(new TextField<String>("searchName",
new PropertyModel<String>(this, "name")));
// searchForm.add(new DropDownChoice<String>("searchComplexity",
// new PropertyModel<String>(this, "complexity")));
searchForm.add(new AjaxLink<String>("searchSubmit") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
modelList = exerciseModel(searchId, name, complexity);
target.add(wmc);
}
});
add(searchForm);
ListView<Exercise> lvExercise = new ListView<Exercise>("lvExercise",
modelList) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<Exercise> item) {
final Exercise model = item.getModelObject();
item.add(new Label("id", Integer.toString(model.getId())));
item.add(new Label("name", model.getName()));
item.add(new ExternalLink("demoUrl", model.getDemoUrl(), model
.getDemoUrl()));
item.add(new Label("complexity", model.getComplexity()
.getLevel()));
item.add(new AjaxLink<String>("edit") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
renderAddExercise(item.getModelObject());
mwAddExercise.show(target);
}
});
item.add(new AjaxLink<String>("delete") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
exerciseJdbc.disableExercise(model);
target.add(wmc);
}
});
}
};
wmc.add(lvExercise);
add(wmc);
mwAddExercise.setWindowClosedCallback(new WindowClosedCallback() {
private static final long serialVersionUID = 1L;
public void onClose(AjaxRequestTarget target) {
target.add(wmc);
}
});
AjaxLink<String> addExercise = new AjaxLink<String>("addExercise") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
renderAddExercise(new Exercise());
mwAddExercise.show(target);
}
};
add(addExercise);
}
private LoadableDetachableModel<List<Exercise>> exerciseModel(
final Integer id, final String name, final String complexity) {
LoadableDetachableModel<List<Exercise>> exercideModel = new LoadableDetachableModel<List<Exercise>>() {
private static final long serialVersionUID = 1L;
protected List<Exercise> load() {
return exerciseJdbc.fetchAllExercises(id, name, null,
complexity);
}
};
return exercideModel;
}
private void renderAddExercise(Exercise exercise) {
mwAddExercise.setContent(new AddExercisePanel(mwAddExercise
.getContentId(), exercise, mwAddExercise));
}
public Integer getSearchId() {
return searchId;
}
public void setSearchId(Integer id) {
this.searchId = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getComplexity() {
return complexity;
}
public void setComplexity(String complexity) {
this.complexity = complexity;
}
}
問題は、リンクをクリックしても発生しないことです。
load() メソッドで実行されるメソッドが、正しい引数が渡されたときに期待するものを返すことを確認しました。
どんな助けでもいただければ幸いです
ありがとう