我试图让wicket在点击一个保存按钮后显示一个信息对话框,它会调用一个无法访问AjaxRequestTarget目标的onsubmit。这是代码段
if (trainingmode() && !recordDecision.equalsIgnoreCase("Primary")) {
if (trainingEvalService.compareDecisions(recordDecision, recordSet.getRecordSetId())) {
System.out.println("Validity matchesMaserati: " + trainingEvalService.getTrainingEval().getActual_validity_decision_comment());
// Dialog associated with save button
dialog = new MessageDialog("dialog", "Notice", "Decision Matches " + trainingEvalService.getTrainingEval().getActual_validity_decision_comment() , DialogButtons.OK_CANCEL, DialogIcon.WARN) {
public void onClose(AjaxRequestTarget target, DialogButton button) {
}
};
dialog.open(target) // breaks here without reference to AjaxTarget
} else {
}
}
如何获取对当前AjaxRequestTarget的引用?
答案 0 :(得分:0)
两种方式:
示例:
yourLink.add(new SimpleAttributeModifier("onclick","alert('information')"));
这将显示一个javascript信息,您可以在其上显示信息。
注意: 如果您没有通过链接提交,那么您可以通过将提交代码放在SubmitLink的onSubmit()中来实现。