Jump to content

lacito

Members
  • Posts

    13
  • Joined

  • Last visited

lacito's Achievements

Apprentice

Apprentice (3/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. Hi, Use the servlet context to obtain an InputStream. InputStream is = null; try { is = context.getResourceAsStream("/selfcare/reports/amount.jrxml"); JasperDesign jaspdes = JRXmlLoader.load(is); jasperreport = JasperCompileManager.compileReport(jaspdes); } finally { is.close(); }
  2. Hi, Read this first. http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=76369 1) Create a "total" variable! 2) Variable class (for example) : java.math.BigDecimal 3) Calculation: Sum. 4) Reset type: Report 5) Increment type: None 6) Variable expression: $F{unit_price}.multiply(new java.math.BigDecimal($F{quantity}.intValue())) 7) Initial Value Expression: java.math.BigDecimal.ZERO I hope it helps, Laszlo Code:<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="sales" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" whenResourceMissingType="Key"> <style name="style1" isDefault="true" forecolor="#333333" fill="Solid" hAlign="Center" vAlign="Middle" markup="none" fontName="DejaVu Sans" fontSize="10" pdfFontName="DejaVuSans.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <queryString> <![CDATA[select o.ord_date, o.ord_id, c.company_name, c.title, c.last_name, c.first_name,p.prod_name, oi.unit_price, oi.quantity, oi.currency,cast(to_char(o.ship_date, 'YYYY') as varchar(4)) as _year,cast(to_char(o.ship_date, 'YYYYMM') as varchar(6)) as _monthfrom orders as o inner join customers as c on c.cust_id=o.cust_idinner join orderitems as oi on oi.ord_id=o.ord_idinner join products as p on p.prod_id=oi.prod_idorder by 1, 2, 3, 5, 6, 7]]> </queryString> <field name="ord_date" class="java.sql.Date"/> <field name="ord_id" class="java.lang.Integer"/> <field name="company_name" class="java.lang.String"/> <field name="title" class="java.lang.String"/> <field name="last_name" class="java.lang.String"/> <field name="first_name" class="java.lang.String"/> <field name="prod_name" class="java.lang.String"/> <field name="unit_price" class="java.math.BigDecimal"/> <field name="quantity" class="java.lang.Integer"/> <field name="currency" class="java.lang.String"/> <field name="_year" class="java.lang.String"/> <field name="_month" class="java.lang.String"/> <variable name="total" class="java.math.BigDecimal" calculation="Sum"> <variableExpression><![CDATA[$F{unit_price}.multiply(new java.math.BigDecimal($F{quantity}.intValue()))]]></variableExpression> <initialValueExpression><![CDATA[java.math.BigDecimal.ZERO]]></initialValueExpression> </variable> <pageHeader> <band height="20"> <textField> <reportElement x="455" y="0" width="100" height="20"/> <textElement/> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{total}]]></textFieldExpression> </textField> </band> </pageHeader> <detail> <band height="21" splitType="Prevent"> <line> <reportElement x="0" y="20" width="555" height="1"/> </line> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement mode="Transparent" x="0" y="0" width="55" height="20"/> <textElement textAlignment="Left"> <font size="8"/> </textElement> <textFieldExpression class="java.util.Date"><![CDATA[$F{ord_date}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement mode="Transparent" x="56" y="0" width="30" height="20"/> <textElement textAlignment="Right"> <font size="8"/> </textElement> <textFieldExpression class="java.lang.Integer"><![CDATA[$F{ord_id}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement mode="Transparent" x="87" y="0" width="180" height="20"/> <textElement textAlignment="Left"> <font size="8"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{company_name}!=null ? $F{company_name} : $F{last_name} + ", " + $F{first_name}+ ($F{title}!=null ? ", " + $F{title} : "")]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement mode="Transparent" x="268" y="0" width="180" height="20"/> <textElement textAlignment="Left"> <font size="8"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{prod_name}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement mode="Transparent" x="450" y="0" width="20" height="20"/> <textElement textAlignment="Right"> <font size="8"/> </textElement> <textFieldExpression class="java.lang.Integer"><![CDATA[$F{quantity}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement mode="Transparent" x="471" y="0" width="50" height="20"/> <textElement textAlignment="Right"> <font size="8"/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{unit_price}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement mode="Transparent" x="525" y="0" width="30" height="20"/> <textElement textAlignment="Left"> <font size="8"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{currency}]]></textFieldExpression> </textField> </band> </detail> <pageFooter> <band height="20"> <textField> <reportElement x="455" y="0" width="100" height="20"/> <textElement/> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{total}]]></textFieldExpression> </textField> </band> </pageFooter></jasperReport>
  3. Hi, I have not tried this, but probably it helps. Use variables. Store the field values of the record in them. Set the calculation attribute to Nothing in the variables. variableExpression for v1 = $F{field1} ... variableExpression for vn = $F{fieldn} At the top of page show variables in the text fields. Or if it does not work, read the Variables chapter in "The JasperReports Ultimate Guide". You can learn some pretty good tricks from this book. :) Laszlo
  4. Hi, If I were you I would try to obtain a connection first and check if it is null. Do you use JNDI for this connection? Then you should check the settings. I hope it helps, Laszlo
  5. Hi, You can find ImageServlet.java in the following folder: src\net\sf\jasperreports\j2ee\servlets\ I hope it helps, Laszlo
  6. Not the best solution but I think it works... Use three fields (f1, f2, f3) on the same place (coordinates). f1 has #BOLD# style f2 has #ITALIC# style f3 has #UNDERLINE# style Set the printWhenExpression of each fields. There is a sampe on jasperforge.org: http://jasperforge.org//uploads/publish/jasperreportswebsite/trunk/samples/FirstJasper.jrxml http://jasperforge.org//uploads/publish/jasperreportswebsite/trunk/samples/FirstJasper.pdf Search for the printWhenExpression element int the jrxml file. I hope it helps... Laszlo
  7. Hello, I would like to qoute from the LGPL 3.0 license, then I would like to ask help to interpret it. Quote "An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library." As far as I can understand that part of the license subclasses (which extend LGPL-licensed classes) and classes (which implement LGPL-licensed interfaces) don't have to be LGPL-licensed. Using an interface provided by the Library means (for me): - Instantiating an LGPL-licensed class, calling it's method, using it's public variables. - Calling static method of an LGPL-licensed class. - Using static constants of an LGPL-licensed class. * If that's what they mean when they talk about "use of an interface provided by the Library", then the Application can be licensed using another type of license (BSD, MIT, propietary or commercial, etc.) Right? And subclassing is "deemed a mode of using an interface provided by the Library". And if * is true, then subclasses can be licensed using another type of license (BSD, MIT, propietary or commercial, etc.), too, and not LGPL. (Of course... Nothing prevents you to use LGPL license. :)) And dear friends, I don't want to fan up the fire. I only want to understand LGPL. I hope you can help me. Thanks in advance, Laszlo Sas Post Edited by lacito at 07/14/2010 08:46
  8. Thank you for the fast answer! :) Regards, Laszlo
  9. Dear developers, We have developed a web application which uses JasperReports 3.7.3. We use Tomcat 6.0.26 as a container. (Win XP, JDK 1.6.0_10) We shutted down Tomcat, and we found the following messages in the catalina.log file: SEVERE: A web application created a ThreadLocal with key of type [null] (value [net.sf.jasperreports.engine.util.JRFontUtil$1@19d373]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed. It seems to be a leak. Can you confirm it? Thanks, Laszlo Sas
  10. Hello, JRResultSetDataSource does not close the used InputStream and Reader in the following methods: protected byte[] readBytes(Integer columnIndex) throws SQLException, IOException public Object getFieldValue(JRField field) throws JRException protected String clobToString(Clob clob) throws JRException Probably it's not a problem, because most JDBC implementations return ByteArrayInputStream when you call clob.getCharacterStream(), blob.getBinaryStream() or resultSet.getCharacterStream(...), but it would be better to close these streams. Thanks, Laszlo
  11. Hello JasperReports users, If an imageExpression returns an InputStream, would the InputStream instance be closed by JasperReports engine? If not, then how/where can I close the stream? Thanks, Laszlo
×
×
  • Create New...