Jump to content

jmurray

Members
  • Posts

    401
  • Joined

  • Last visited

 Content Type 

Forum

Downloads

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Security Advisories

Events

Profiles

Everything posted by jmurray

  1. If you want to put table based data into a header section then the simplest way to do it is by using a subreport. All your tabulation and calculations are performed in the detail section of the subreport. The subreport is inserted into the header section of the main report and linked (if necessary) to some key value. If the key value is report-wide then it is generally passed in as a parameter, and the subreport can reside in the report or page header. If the key value changes during report creation then you have to use groups and insert the subreport into a group header.
  2. Yes, there was a typo in my posting! Bugger. The Variable Expression was missing a closing parenthesis, so enter this instead: new java.lang.Integer($F{NAME}.equals( $P{NAME} ) ? 1 : 0 ) Everything else stays the same. You must stop using "==" to compare Strings. Very, very much badness.
  3. Posting as a bug as behaviour does not conform to that described in the JasperReports documentation.
  4. Lots of issues here: First, you can't use If..Then..Else..Endif. You have to use ( comparison ? action when true : action when false ) Next up $F{NAME} and $P{NAME} are likely to be Strings already so there's no need to perform a .toString on them. It is very bad karma to perform a String==String comparison. Use .equals() instead. You can't change the value of a field, so trying to increment $F{COUNT} won't work. Use a variable instead. Using reserved words like NAME and COUNT as variable, field or parameter names is asking for trouble. -------------------- The solution is to set up a java.lang.Integer variable called $V{myCOUNT} with an Initial Value Expression of new java.lang.Integer(0) and a Calculation Type of "Sum". Then set your Variable Expression to new java.lang.Integer($F{NAME}.equals($P{NAME} ? 1 : 0 ). This will increment $V{myCOUNT} whenever the contents of $F{NAME} match the contents of $P{NAME} otherwise do nothing. . Post edited by: jmurray, at: 2007/05/09 23:13
  5. duplicate post removed Post edited by: jmurray, at: 2007/05/09 23:13
  6. You have to imagine your expressions as being an inline piece of Java (because that's what they will be when the xml is interpreted by the report engine!). All of the expression boxes will resolve to a specific java class (eg. java.lang.String or java.lang.Integer or java.util.Date) as specified by you. Your raw expressions will always result in a primitive such as string, integer, or boolean. The construct for a primitive does not match the construct for a class, so you'll always end up with an exception. So you need to recast as part of your expression. Let's say you have an expression box that expects a java.lang.Boolean to be returned. If you enter an expression like this: $V{REPORT_COUNT}.intValue>1 then the result will be boolean and you'll get an exception because boolean != Boolean. You need to wrap it in a cast to Integer like this: new java.lang.Boolean($V{REPORT_COUNT}.intValue>1)
  7. I'm unable to get a PDF hyperlink to open a new browser window even though i set Target="Blank". Code: <image evaluationTime="Now" hyperlinkType="Reference" hyperlinkTarget="Blank" > <reportElement x="69" y="1" width="9" height="9" key="image-2"> <printWhenExpression><![CDATA[new java.lang.Boolean(($F{TickLevel}.intValue()>0) && ($P{RENDERING}.toString().compareTo("PDF"«»)==0))]]></printWhenExpression> </reportElement> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <graphicElement stretchType="NoStretch"/> <imageExpression class="java.lang.String"><![CDATA["/usr/share/tomcat5/webapps/ROOT/reports/src/DigiToll/PROXY/img/grn_tick_lg.bmp"]]></imageExpression> <hyperlinkReferenceExpression><![CDATA["http://portal.networks.det.nsw.edu.au/pni/jsp/faq.jsp#Other2"]]></hyperlinkReferenceExpression> </image> Haven't found a reference to this type of issue elsewhere in the forum. Any ideas?
  8. Yeah, that's what it is meant to do. Each of the _COUNT system variables returns the number of detail rows for the relevant section. Page numbering is explained in the JasperReports FAQ http://jasperforge.org/sf/wiki/do/viewPage/projects.jasperreports/wiki/FAQ7
  9. It appears to be a fixed value. Can't see anything that allows you to change it from the default of 5 pixels.
  10. When naming your fields, variables, and parameters you need to avoid using reserved words. The original post had $P{SELECT}, and SELECT is a reserved word in SQL. Maybe you are suffering the same problem because your parameter name is based on some reserved word that is interpreted in a manner that creates an error.
  11. The output of jasper reports is static. Can you explain what you want to achieve in more detail please?
  12. check out the INTEGER, CEILING and FLOOR functions in the Derby Reference Manual http://db.apache.org/derby/docs/dev/ref/refderby.pdf
  13. I don't know. FWIW I had to upgrade when I went to 1.2.6, so I'd say 1.2.3 is pretty much the last one. Giulio or Teodor might be able to name the exact version. . Post edited by: jmurray, at: 2007/03/19 22:58
  14. You need to upgrade to at least J2SE 5.x (version 6 is out now), and copy the updated tools.jar and any other jars that you need into the iReports/lib directory. J2SE 5 is available from Sun at http://java.sun.com/javase/downloads/index_jdk5.jsp J2SE 6 is available from Sun at http://java.sun.com/javase/downloads/index.jsp Post edited by: jmurray, at: 2007/03/19 21:39
  15. You should really ask new questions in a new post. You might find what you're after here: http://www.jasperforge.org/index.php?option=com_mamblog&Itemid=109&task=show&action=view&id=246&Itemid=109
  16. The Print When expression you would use is something like this: new java.lang.Boolean($V{REPORT_COUNT}.intValue()==0) But be careful: the value of REPORT_COUNT is not available until AFTER the detail section has been filled. That means that you can normally only use that expression in a footer or summary section. There is a way around the problem though. You can use a subquery to return the value BEFORE the detail section is filled because subreports are always filled first. The subreport doesn't need to display anything, it just returns the value of REPORT_COUNT so that you can store it in your own variable within the main report. The subreport's query is the same as the query in the main report. The best place to put it is in a header section, out of the way. Once your variable has the value of REPORT_COUNT from the subreport you can use it in any subsequent band, including the Detail band. The expression now has to refer to your own variable: new java.lang.Boolean($V{yourVariable}.intValue()==0)
  17. This is a forum: nothing is urgent. If someone knows a solution they will post it. and you forgot to put the attachment in you post. It isn't possible to answer you Q without it.
  18. Generally you would call it as part of your query in the normal way, like this: SELECT column1, colum2, yourfunction(somecolumn) as column3 FROM tablename; If you just want to get a single piece of information for the header then you still use a query but embed the query in a subreport.
  19. You can do this in the either source query or in the expression. To do it in the data source you use functions available in the database. This is an ORACLE example: SELECT field1 , field2 , DECODE(eq_res,'D','Daily','M','Monthly','H",'Hourly','') AS eq_res FROM yourTable Then your expression would simply be $F{eq_res} This is what you would do if you want to manipulate $F{eq_res}within an expression: new java.lang.String($F{eq_res}=="D" ? "Daily" : ($F{eq_res}=="M" ? "Monthly" : ($F{eq_res}=="H" ? "Hourly" : "") ) ) Post edited by: jmurray, at: 2007/03/17 02:37
  20. I just noticed a mistake in the posting. The double quote should be escaped with a backslash, but when I pasted it into the forum the backslash got stripped. So the example that read $P{REPORT_SCRIPTLET}.formatDecimal($F{your IntegerField},new java.lang.Integer(3),""",new java.lang.Boolean(true)) should actually have read Code:$P{REPORT_SCRIPTLET}.formatDecimal($F{your IntegerField},new java.lang.Integer(3),""",new java.lang.Boolean(true)) . Post edited by: jmurray, at: 2007/03/16 10:39
  21. You could use a bit of code in a scriptlet. I don't know java, so you'll have to forgive me if the following code makes your eyes bleed: Code:public String formatDecimal(Integer myIntegerValue, Integer myDecimalPlaces, String myDecimalSeparator, Boolean myLeadingZero) throws JRScriptletException { String decimalSeparator = (java.lang.String)( myDecimalSeparator == "" ? "." : myDecimalSeparator ); Integer decimalPlaces = (java.lang.Integer)( myDecimalPlaces.intValue()); String integerValue = (java.lang.String)(myIntegerValue.toString()); String fractionalPart = (java.lang.String) (""«»); String integerPart = (java.lang.String)( myLeadingZero.booleanValue() == true ? "0" : "" ); if (decimalPlaces.intValue()>integerValue.length()) { fractionalPart = repeat(decimalPlaces.intValue()-integerValue.length()) + integerValue; } else { integerPart = integerValue.substring(0,(integerValue.length()-decimalPlaces.intValue())); fractionalPart = integerValue.substring(integerValue.length()-decimalPlaces.intValue()); } if (decimalPlaces.intValue()==0) { decimalSeparator = ""; } return integerPart + decimalSeparator + fractionalPart ; } public static String repeat(int i) { String returnValue = ""; for(int j = 0; j < i; j++) { returnValue = returnValue + "0"; } return returnValue; } You call it with four parameters: the Integer value the number of decimal places (as Integer) the decimal separator (as String) whether you want to force a leading zero (as Boolean) So you would set your expression to be something like: $P{REPORT_SCRIPTLET}.formatDecimal($F{your IntegerField},new java.lang.Integer(3),""",new java.lang.Boolean(true)) Of course you can replace the static parameter settings with parameters or variables. If you want to handle errors (like negative number of decimal places) then you'll need to add that into the code.
  22. You can define any expression using a standard java comparison expression to convert values The following expression will return 1 if the GENDER field contains "M", otherwise it returns 2: new java.lang.Integer( $F{GENDER} == "M" ? 1 : 2 ) To take it further to cope with males, females, and gender neutral categories you simply add another comparison, like this: new java.lang.Integer( $F{GENDER} == "M" ? 1 : ( $F{GENDER} == "F" ? 2 : 3 ) ) This will return 1 for GENDER="M", 2 for GENDER="F", and 3 for any other value. It is up to you to handle case sensitivity (ie. "m" <> "M")
  23. You didn't select a value from the list because "single" <> "Single". Java is case sensitive, specify "Single" and you're report will run fine.
  24. Take a close look at the error messages, particularly this bit: Caused by: java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''lc'.requests' at line 1 Notice how the dB specifier is quoted? This is because you specified $P{dbname}, which puts quotes around its contents. If you want to insert the contents without the quotes you need to specify $P!{dbname}
  25. The problem is that the data is being placed into cells that are have 'General' formatting (the Excel default)applied. That means that Microsoft Excel will look at the incoming data and apply what it thinks is the best display formatting for what it sees. You have to come in afterwards and reformat the cells at 'Number' with x decimal places if Excel make an inappropriate decision.
×
×
  • Create New...