PDA

View Full Version : Spring and Jasper integration problem


directips
Dec 10th, 2007, 07:01 AM
I have problems to visualize pdf in web.

My steps:

1. Generate .jrxml with iReport 2.0.2

2. Compile file and generate .jasper element

I test to visualize in pdf mode with iReports visualizer and it runs!

3. Include .jasper file in project

/WEB-INF/reports/file.jasper

4. Activate jasper dependency in pom.xml (I use Maven 2.0)

5. Activate Servlet

<bean id="reportsViewResolver"
class="org.springframework.web.servlet.view.ResourceBundl eViewResolver">
<property name="basename">
<value>views</value>
</property>
</bean>

6. Configure mapping in views.properties

file.class=org.springframework.web.servlet.view.ja sperreports.JasperReportsPdfView
fileurl=/WEB-INF/reports/file.jasper

7. Create a Controller to mapping url "file.htm"

@UrlMapping("/file.htm")
public class FileController extends GenericController implements
Controller {
...

public ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {

// Set information to model
HashMap<String, String> map = new HashMap<String, String>();
map = getModel(resp);

// Return model and view
return new ModelAndView("file", map);
}
}


The project compile and deploy fine, but when access to url ./file.htm the system generates a white pdf, without and element, only a white pdf page.

Any idea?

Thanks!

directips
Dec 10th, 2007, 08:18 AM
Well...

i find the problem

You must include JRDataSource in parameters map

map.put("JRDataSource", new JREmptyDataSource());

And runs!


Sorry!