milindk740 Posted January 7, 2014 Share Posted January 7, 2014 I have a requirement wherein I have to add a search box and dropdown to jasper report which displays user details. I am using iReport to create jasper template. Can we add a search box and dropdown to the template itself? The report will be rendered in the HTML format on the UI displaying the user details. Now the task of the search box would be to display the details of the specific user that the client inserts in the search box. I could not find any element to do so. Can any one help. Link to comment Share on other sites More sharing options...
Ankur Gupta Posted January 7, 2014 Share Posted January 7, 2014 Hi,Can we add a search box and dropdown to the template itself? I am assuming that you are using to create your reports using iReport, so there we can add parameters which could be filled via Jasper server using the UI of the filters, as far as I know we cannot add the UI components like dropdown or search box in the template.Now the task of the search box would be to display the details of the specific user that the client inserts in the search boxThis could be achieved by setting up the query to retrieve the records in creating the IMPUT CONTROLS in Jasper Server and there we could get the drop down or search box to find or list the different users or whichever list of people are added to be selected as filter.Hope that this helps.ThanksAnkur Guptahttp://ankurthetechie.blogspot.in/ Link to comment Share on other sites More sharing options...
milindk740 Posted January 7, 2014 Author Share Posted January 7, 2014 @Ankur What is the purpose of the server here, could you help me understand that. I will be creating the report template using IReport. Then using java code, I will be displaying the report on the UI. Link to comment Share on other sites More sharing options...
Ankur Gupta Posted January 7, 2014 Share Posted January 7, 2014 Hi,As you want to integrate Jasper Reports in the a Java web application then what could be done is that use the iReport to design the reports, so you will have JRXML file of the report now as you require the value from the application via Search box or Dropdown so you can place these in the application and Java you can simply set the parameters of the report created in iReport via java program , and then again via the same program you can execute the report with aggregated paramters from the search box and drop down, now for comipling and setting the parameters in the report (JRXML file) programatically via a java program you need to make of the package net.sf.jasperreports.engine.design contained in the jar file jasperreports-x.x.x.jar (x defines the version of the jar).This Jar file could be easily find in the directory where the iReport is installed. (Location where iReport is installedireportmodulesext)A sample for the code is Class.forName("com.mysql.jdbc.Driver");[/code]Connection conn =DriverManager.getConnection("jdbc:mysql://localhost:3306/student","username","pass");[/code]ResultSet rs=conn.createStatement().executeQuery("SELECT * FROM student_details "); [/code]JRResultSetDataSource jrrsds= new JRResultSetDataSource(rs);[/code]JasperDesign jasperDesigns = JRXmlLoader.load("Path of the JRXML rport created by iReport");[/code]JasperReport jasperReports = JasperCompileManager.compileReport(jasperDesign);[/code]JasperPrint jasperPrints = JasperFillManager.fillReport(jasperReports, new HashMap(),jrrsds);[/code]JasperExportManager.exportReportToHtmlFile(jasperPrint, "Path to export as HTML") ;[/code]JasperViewer.viewReport(jasperPrint); // Could be set wherever you want to view the report[/code]Hope that above information helps.Thanks,Ankur Guptahttp://ankurthetechie.blogspot.in/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now