@RequestMapping(value = "/generateReport", method = RequestMethod.POST)
public ModelAndView generateReport(@ModelAttribute("MstKraEmpBean") MstKraEmpBean userBean,KrahdrBean krahdrBean, BindingResult result, RedirectAttributes redirectAttributes, ModelMap map, HttpServletRequest req)
{
try {
Map<String, Object> parameterMap = new HashMap<String, Object>();
List<MstKraEmp> userBean1 = null;
userBean1 = KRAService.getEmployee(17);
JRDataSource JRdataSource = new JRBeanCollectionDataSource(userBean1);
parameterMap.put("pDataSource", userBean1);
parameterMap.put("pLength", 123);
JasperPrint jasperPrint = JasperFillManager.fillReport("E:/StyledTextReport/KRA_Test.jasper",parameterMap,JRdataSource);
File outDir = new File("E:/jasperoutput");
outDir.mkdirs();
JasperExportManager.exportReportToPdfFile(jasperPrint,outDir.getPath()+"/KRA_Test.pdf");
System.out.println("Name : "+userBean1.get(0).getName() + "Pass : " + userBean1.get(0).getPwd());
System.out.println("Size : "+userBean1.size());
} catch (JRException e) {
e.printStackTrace();
}
System.out.println("Done!");
return new ModelAndView("Report");
}
I want to use Data Object instead of List Because i face the issue to print the name in jasper report example : $P{pDataSource}.get(0).getName() : But Issue
Comments
Post a Comment