在我的面板中,我将 listView 添加到具有可拆卸模型的表中:
编辑:
public class TaskDetailsPanel extends Panel {
...
public TaskDetailsPanel(String id, CompoundPropertyModel<LongRunningTask> model) {
super(id, model);
Task task = (LongRunningTask) getDefaultModelObject();
List<Timeframe> testList = task.getTimeframes();
DetachableTimeframeModel dtm = new DetachableTimeframeModel(new Model<Task>(task));
ListView frames = new ListView("frame", dtm) {
@Override
protected void populateItem(ListItem item) {
Timeframe tf = (Timeframe) item.getModelObject();
item.add(new Label("time", "von - bis"));
item.add(new Label("sentFiles", String.valueOf(tf.getSentFiles())));
item.add(new Label("receivedFiles", String.valueOf(tf.getReceivedFiles())));
item.add(new Label("missingMsgIds", String.valueOf(tf.getMissingMsgIds())));
item.add(new Label("receivedMsgIds", String.valueOf(tf.getReceivedMsgIds())));
}
};
frames.setOutputMarkupId(true);
add(frames);
...
}
}
这是我的自定义 detable 模型:
class DetachableTimeframeModel extends LoadableDetachableModel {
LongRunningTask task;
public DetachableTimeframeModel(LongRunningTask t) {
task = t;
}
@Override
protected List<Timeframe> load() {
return task.getTimeframes();
}
}
当我在面板内定义一个新的列表List(例如ArrayList)并向其中添加项目时,它就可以工作了。但是当列表来自另一个 javabean 时,它会失败。
我错过了什么?