Announcement Announcement Module
Collapse
No announcement yet.
JasperReportsMultiFormatView with runtime config Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JasperReportsMultiFormatView with runtime config

    Hi,

    I am trying to use JasperReportsMultiFormatView with everything configured at runtime but can not get it work.

    I do not want any properties-file with configuration.

    What I try to do seems logical to me. What could be wrong?

    Here is my code:


    Code:
    ...
    
    public class DaController {
    
    	@Resource(name = "sessionFactory")
    	private SessionFactory	sessionFactory;
    
    ...
    
    	@RequestMapping(value = "/application/report2", method = RequestMethod.GET)
    	public JasperReportsMultiFormatView handleSimpleReportMulti(final ModelMap modelMap, final HttpServletRequest request, final HttpSession httpSession) {
    
    		final Session session = sessionFactory.getCurrentSession();
    
    		final ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(httpSession.getServletContext());
    
    		modelMap.addAttribute("testName", "test report");
    		modelMap.addAttribute("REPORT_CONNECTION", session.connection());
    		modelMap.addAttribute("itemName", "1");
    		modelMap.addAttribute("format", "pdf");
    
    		final JasperReportsMultiFormatView v = new JasperReportsMultiFormatView();
    		v.setAttributesMap(modelMap);
    		v.setApplicationContext(ctx);
    		v.setUrl("/WEB-INF/offer.jrxml");
    		v.setContentType("application/pdf");
    		v.setFormatKey("pdf");
    
    		return v;
    
    	}
    }
Working...
X