我试图覆盖Wicket Palette的某些功能。我附上了一张我想用Palette完成的图片。基本上除了Palette的select-item-clickbutton-moveToRight功能之外,我还想知道在移动之前选择了哪个项目。当我在任一面板中选择一个项目并单击“查看”按钮时,我应该能够从调色板中显示与当前所选项目相关的html页面。 现在,按钮被放置在Palette代码之外,只要我能获得所选元素的ID,我就能完成我的目标。 我被困在需要知道调色板中选择了哪个项目的位置。
这是我到目前为止所尝试的内容:
1.使用AjaxFormComponentUpdatingBehavior将 final Palette classFormMapping = new Palette(" formsPalette",new ListModel(selectedFormsList),
formsList,new CustomObjectChoiceRenderer(),8,false){ final Palette classFormMapping = new Palette(" formsPalette",new ListModel(selectedFormsList),
formsList,new CustomObjectChoiceRenderer(),8,false){ Trying to create this palette with a custom button 请帮忙。提前谢谢。 @Override
protected void onBeforeRender() {
super.onBeforeRender();
getChoicesComponent().add(new AjaxFormComponentUpdatingBehavior("onclick"){
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("REACHED HERE"+ getFormComponent());
/*
* The code reaches here for each click but I am unable to know which item was selected */
}
});
}
};
protected Recorder newRecorderComponent() {
Recorder recorder = super.newRecorderComponent();
recorder.add(new AjaxFormComponentUpdatingBehavior("onclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("reached record on click ");
}
});
return recorder;
}
};
答案 0 :(得分:0)
Palette.java javadoc解释了如何“Ajax-ify”:https://github.com/apache/wicket/blob/529db58c413861677f7ff6736f9363edf42ae85a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java#L52-L71
但这对您没有帮助,因为首先在客户端完成选择,然后通知Wicket: https://github.com/apache/wicket/blob/529db58c413861677f7ff6736f9363edf42ae85a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/palette.js#L118-L127
您需要在Wicket one或monkey-patch palette.js之前为'change'事件注册自己的JS事件监听器以覆盖Wicket.Palette.updateRecorder()
函数。