带有jquery的ajax按钮,用于文件下载
我已经使用了wicket、ajax和jquery。在表单(有两个日期字段)提交时,用户将获得文件下载弹出窗口。由于我使用spinner显示处理过程需要时间,所以这在ajax和jquery上是有效的。 现在的问题是,当我使用正常的wicket submit按钮时,虽然并没有微调器,但报告下载工作正常。但是,当我使用ajaxbutton时,微调器会自动关闭,但没有报告打开/保存弹出窗口 下面的代码工作正常,并提供了打开/保存弹出窗口,但由于没有ajax操作,所以不会显示微调器带有jquery的ajax按钮,用于文件下载,jquery,ajax,wicket,Jquery,Ajax,Wicket,我已经使用了wicket、ajax和jquery。在表单(有两个日期字段)提交时,用户将获得文件下载弹出窗口。由于我使用spinner显示处理过程需要时间,所以这在ajax和jquery上是有效的。 现在的问题是,当我使用正常的wicket submit按钮时,虽然并没有微调器,但报告下载工作正常。但是,当我使用ajaxbutton时,微调器会自动关闭,但没有报告打开/保存弹出窗口 下面的代码工作正常,并提供了打开/保存弹出窗口,但由于没有ajax操作,所以不会显示微调器 add(new Sub
add(new SubmitLink("runReport") {
*//**
*
*//*
private static final long serialVersionUID = 10011L;
*//**
*
*//*
@Override
public void onSubmit() {
HashMap<String, Object> map = new HashMap<String, Object>();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
map.put("reportStartDate", formatter.format(getReportStartDate()));
// Add a day to the end date to include the date entered by the user.
Calendar cal = Calendar.getInstance();
cal.setTime(getReportEndDate());
cal.add(Calendar.DATE, 1);
map.put("reportEndDate", formatter.format(cal.getTime()));
generateReport(map,"ecommerceReport.rptdesign");
}
}
.add(RelativePathPrefixHandler.RELATIVE_PATH_BEHAVIOR)
);
添加(新提交链接(“运行报告”){
*//**
*
*//*
私有静态最终长serialVersionUID=10011L;
*//**
*
*//*
@凌驾
提交时公共无效(){
HashMap=newHashMap();
SimpleDataFormat格式化程序=新的SimpleDataFormat(“yyyy-MM-dd”);
put(“reportStartDate”,formatter.format(getReportStartDate());
//在结束日期后添加一天,以包括用户输入的日期。
Calendar cal=Calendar.getInstance();
cal.setTime(getReportEndDate());
计算添加(日历日期,1);
map.put(“reportEndDate”,formatter.format(cal.getTime());
generateReport(地图,“ecommerceport.rptdesign”);
}
}
.add(RelativePathPrefixHandler.RELATIVE\u路径\u行为)
);
下面的代码将spinner显示为其ajax,但没有打开/保存弹出窗口
AjaxButton runReportButton = new AjaxButton("runReport", this) {
private static final long serialVersionUID = 10008L;
@Override
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
HashMap<String, Object> map = new HashMap<String, Object>();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
map.put("reportStartDate", formatter.format(getReportStartDate()));
// Add a day to the end date to include the date entered by the user.
Calendar cal = Calendar.getInstance();
cal.setTime(getReportEndDate());
cal.add(Calendar.DATE, 1);
map.put("reportEndDate", formatter.format(cal.getTime()));
generateReport(map,"ecommerceReport.rptdesign");
target.addComponent(form);
}
};
runReportButton.add(RelativePathPrefixHandler.RELATIVE_PATH_BEHAVIOR);
runReportButton.add(new SimpleAttributeModifier("onmouseup", "showPopup();"));
add(runReportButton);
AjaxButton runReportButton=新的AjaxButton(“runReport”,这个){
私有静态最终长serialVersionUID=10008L;
@凌驾
提交时公共无效(AjaxRequestTarget目标,表单){
HashMap=newHashMap();
SimpleDataFormat格式化程序=新的SimpleDataFormat(“yyyy-MM-dd”);
put(“reportStartDate”,formatter.format(getReportStartDate());
//在结束日期后添加一天,以包括用户输入的日期。
Calendar cal=Calendar.getInstance();
cal.setTime(getReportEndDate());
计算添加(日历日期,1);
map.put(“reportEndDate”,formatter.format(cal.getTime());
generateReport(地图,“ecommerceport.rptdesign”);
target.addComponent(表单);
}
};
添加(RelativePathPrefixHandler.RelativePath\u行为);
添加(新的SimpleAttributeModifier(“onmouseup”,“showPopup();”));
添加(运行报告按钮);
即使以下代码也不起作用:
add(new AjaxFallbackButton("runReport", this) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
HashMap<String, Object> map = new HashMap<String, Object>();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
map.put("reportStartDate", formatter.format(getReportStartDate()));
// Add a day to the end date to include the date entered by the user.
Calendar cal = Calendar.getInstance();
cal.setTime(getReportEndDate());
cal.add(Calendar.DATE, 1);
map.put("reportEndDate", formatter.format(cal.getTime()));
generateReport(map,"ecommerceReport.rptdesign");
target.addComponent(form);
}
});
add(新的AjaxFallbackButton(“runReport”,此选项){
@凌驾
提交时受保护的void(AjaxRequestTarget目标,表单){
HashMap=newHashMap();
SimpleDataFormat格式化程序=新的SimpleDataFormat(“yyyy-MM-dd”);
put(“reportStartDate”,formatter.format(getReportStartDate());
//在结束日期后添加一天,以包括用户输入的日期。
Calendar cal=Calendar.getInstance();
cal.setTime(getReportEndDate());
计算添加(日历日期,1);
map.put(“reportEndDate”,formatter.format(cal.getTime());
generateReport(地图,“ecommerceport.rptdesign”);
target.addComponent(表单);
}
});
任何帮助,我做错了什么这个来自Wicket wiki的解决方案应该适合您-它可以启动任何类型Ajax请求的下载:
该链接已失效:\我添加了新链接。显然,ApacheWiki移动了。