Jump to content
We've recently updated our Privacy Statement, available here ×

Alexander Merz

Members
  • Posts

    37
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by Alexander Merz

  1. Parameters are a way to pass arbitrary data into the report, where the data does not come from the data source. For example in your application you want to include the name of the user who is currently logged in and wants to get a report. Code: String userName = ... ... HashMap params = new HashMap(); params.put("user", userName); ... JasperPrint jp = JasperFillManager.fillReport(report, params, datasource); In the JRXML: Code:[code] <parameter name="user" class="java.lang.String"/> ... <textField> ... <textExpression><![CDATA[$P{user}]]></textExpression> </textField>
  2. The second parameter is a Map object for parameters. Parameters are defined in the report via <parameter>. See the Tag reference and API docs for more information.
  3. Code:parameters.put("condition",condition); Code:[code]<parameter name="cond" class="java.lang.String"> Code:[code]<queryString> ... $P!{cond} order by Issuedate;]]> </queryString> BTW: I hope the java code is only a demo/reduced and will not run under a public avaible service... Post edited by: Alexander Merz, at: 2006/09/10 23:50
  4. Check the API-Doc of JRHtmlExporterParameter and take care of the correct URI to the images.
  5. If your column names could change, you should may be implement you own data source and add a flexible mapping of fixed field names to variable column names. But, i did not really understand why column names are a subject to change. As long as your data model isn't stable, it isn't a good idea to start with a report implementation.
  6. Via JRParameter.REPORT_LOCALE. But this parameter is relevant for the export only AFAIK. I would agree with Barry, there seems to be a problem in the underlying enviroment. You say in iReport, everything is ok, but at the stage/developer deployment level the error occurs. Do you run the processing of the report under the application server? They often use some "strange" settings and come with their own libs.
  7. Note: I'm from Germany, so i'm familiar with the problem of special chars. Not only in having correct encodings in JRXML files. And my experience with Eclipse related to encoding stuff is: it's ugly, it's intransparent. Never use Eclipse to change or repair encodings in texts. (That's not Eclipse specific, the most IDEs seem to be the wrong tools for this task) Use a relativ simple editor (i use ConText). Open the file in the editor and remove the CDATA sections and texts in the static text boxes. Save the file and try to compile it. If it works, go back to the editor and add the texts again. ConText stores the file in ISO-8859-1 by default, so take care of setting <?xml version='1.0' encoding='ISO-8859-1' ?> Compile again, if it works, be happy and be careful, if you touch the JRXML in the future again. If it does not compile with empty text boxes, then you may have unusal chars somewhere in the file. You could enable ConText feature to show you unprintable chars in the file and look over it. But i guess (seeing the file size) this would require pratically more time then setting up a new report template from scratch.
  8. AFAIK JasperReport tries to analyse the pattern and checks if it contains some of the constants like hide or short. If the detection fails, the pattern is passed to SimpleDateFormat directly. The error message is generated by SimpleDateFormat, if the pattern contains characters not known by the parser. So the detection of the constants must have failed. I don't not know when the "style"-feature was introduced, but I could imagine, that the feature isn't avaible in older releases. Another possibility would be just a typing mistake like "nedium,hide". Post edited by: Alexander Merz, at: 2006/09/02 08:54
  9. Look at this staticText element: Code:<staticText> <reportElement ... key="element-90"/> <box ... /> <textElement> <font fontName="" size="12"/> </textElement> <text><![CDATA[identificación]]></text> </staticText> The text is encoded in UTF-8, not ISO-8859-1! Could it be possible, that you used several editors to edit the file? Maybe one of them is setted to store in UTF-8 by default. I can remember at least one editor that changes and stores the file content to UTF-8 automatically by default in such a case, independent of the encoding before. The result is just a mangled file, in the worst case you have a mix of encodings for special chars in the file.
  10. Do you want to iterate over the HashMap or do you have a list of HashMaps? To iterate you would need to implement your own datasource class. If you have list, you should take a look on JRMapCollectionDataSource.
  11. Be careful, if you manually change the encoding in the JRXML, for example to ISO-8859-1: <?xml version="1.0" encoding="ISO-8859-1" ?> and then load the file again in iReport, it is changed to UTF-8 again. But it only changes the encoding attribute, not the encoding of the file itself! I don't know if this is really bug of iReport or just a result of how the file and the XML is processed in some underlying layers/libraries.
  12. I'm not sure, but according to the docs, you can use JRExporterParameter.OFFSET_X and JRExporterParameter.OFFSET_Y as parameters for the export class to move the page content while exporting. So you could change the report xml template to have no margins and add margins via the parameters for all cases of export, which are not Xls and Text. But i never used it actually. So i don't know if this would really work like i imagine.
  13. Look for the <group> tag in the tag reference (docs/reference). There are also many examples in the demo/samples and doc/samples directory using the tag.
  14. Make sure that there is no space or blank line before <?xml version="1.0" encoding="UTF-8" ?> And there should be no space or Non-XML-data after the line and before the <jasperReport>-tag.
  15. Code:java.lang.NoClassDefFoundError: org/apache/commons/javaflow/bytecode/Continuable indicates that commons-javaflow is missing. Check, if your classpath contains a reference to commons-javaflow-*.jar
  16. Code:JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(fileGen); if(!jasperPrint.getPages().isEmpty()) { jpl.add(jasperPrint); }
  17. Ok, look on this lines in your code: Code: File sourceFile = new File( NOM_ARCHIVO ); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); Remember the content of NOM_ARCHIVO? Code:[code] NOM_ARCHIVO = rutaReportesBIRT + "WebappReport.jrxml"; You trying to load the JRXML file, what is nonsense, because the method creates a JasperPrint object from a serialized JasperPrint object stored in a file. But the JRXML does not contain such an serialized object. For your first trials, try this way: Instead of saving the results to file pass it directly to a variable. Code:[code]JasperReport jasperReport = JasperCompileManager.compileReport( NOM_ARCHIVO ); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parametros, getConnection()); The rest seems to be ok. Post edited by: Alexander Merz, at: 2006/08/31 08:11
  18. Sounds like a variation of http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=view&id=652&catid=8
  19. See the batchexport example in the demo/samples directory of the JR distribution.
  20. Creating a report requires three steps: - compile the report xml template - filling with data - exporting to something viewable The methods in JasperRunManager hide these steps. To make each step manually: Responsible for compiling -> JasperCompileManager filling -> JasperFillManager exporting -> the already mentioned Exporter classes
  21. Sorry, some misunderstanding. You must set the position of the text field. You can influence the padding and alignment of a text in a textField element: Code:<textField> <reportElement x="0" y="0" width="100" height="50"/> <box padding="0" /> <textElement textAlignment="Right" /> <textFieldExpression> <![CDATA["foobar"]]> </textFieldExpression> </textField> But these values do not influence the padding or alignment of the text field related to the surrounding band.
  22. Study the webapp example carefully. You need to configure your web application server correctly. The URL path "servlets/image" is not a path in the filesystem, it is an assignment of a servlet class. See the file WEB-INF/web.xml in the example: Code: <servlet-mapping> <servlet-name>ImageServlet</servlet-name> <url-pattern>/servlets/image</url-pattern> </servlet-mapping> The servlet-name refers to the servlet class: Code:[code]<servlet> <servlet-name>ImageServlet</servlet-name> <servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class> </servlet> This class is located in WEB-INF/classes/net/sf/jasperreports/j2ee/servlets/ImageServlet. Again: it looks like a missing configuration for the servlet. If you use Tomcat you can copy the existing WEB-INF directory or copy the required configuration parts and classes to the WEB-INF to your existing application. For other web application servers you may need additional steps, consult the server docs about adding a servlet. Post edited by: Alexander Merz, at: 2006/08/29 20:02
  23. Nitpick: It is not possible to move the summary *section* at the top. But you can move a page having a specific text to another position. But this is not the problem here, the exception is thrown before moveTableOfContents() is called. I feel a little out of context. The warning does occur in your real application? The given code is only a demonstration? In your demo you don't provide any references to the sub reports. I guess JasperReports can successfully load main.jrxml, but fails while trying to load the files for the sub reports.
  24. <textElement> allows to set the text alignment via the attribute textAlignment, in <box> you can use the padding* attributes to control the space between the border of the text field and the text. I don't like the Auto-feature, it spreads information about the evalution time of a text field to several locations in the JRXML. It is a potenzial source for problems, which are easy to introduce, but hard to find, especially if your are not the initial designer.
×
×
  • Create New...