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

teamdebo

Members
  • Posts

    8
  • Joined

  • Last visited

teamdebo's Achievements

Rookie

Rookie (2/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. I need to calculate a media of all value of vertain field. So I figured that I need to do custom calculation on the variable since there is no "median" calculation type. There is a Calculation type called System for variables, I have been trying to find information about how to use it. I undertand that System calculation for variables allowes you to do custom calculation but there is no informaiton on the web about how to actually use it. Does anyone know how to use System for custom calc? thank you
  2. after even further trial and error hours wasted I came up with this: ( $F{fieldA}.matches("[0-9]+") ? new java.lang.Integer($F{fieldA}) : new java.lang.Integer('0')) This appears to work in the sense that it does not throw any exceptions and actually compiles. Can anyone tell me if this is a good approach or if there is a better approach or maybe this is a complete nubie solution which I would like to not actually implement. Thank you
  3. Ok so I narrowed the proble down a bit but I still don't know how to fix it. It appears as though the parsing actually works, except some of the string data is not numeric so a NumberFormatException is thrown which is normal for java. Now the problem is how to get around that (If it is possible). Is there some way to catch the exception, or is there a way to parse the string first, check if it has only numerics and only in that case attempt to parse it into integer? Does anyone know how to do this? Thanks
  4. Hi, I am new to jasperserver and iReports, however I do know java pretty well. I have a question which has been bugging me for a long time because I can't seem to figure it out and its so simple I should be able to find the answer. I have a field: fieldA it is a string I want to calculate the average, min, max and median, but for now I just need to figure out one of those and the rest will be simple. What I did was create a variable avgFieldA class: java.lang.Integer initial value: java.lang.Integer.valueOf(0) expression: java.lang.Integer.parseInt($F{fieldA }) then I display this variable with: $V{avgFieldA} but I keep getting the following error: Code:Error filling print... Error evaluating expression :     Source text : java.lang.Integer.parseInt($F{fieldA}}) Setting up the file resolver... net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :     Source text : java.lang.Integer.parseInt($F{fieldB})     at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:259)     at net.sf.jasperreports.engine.fill.JRCalculator.evaluateEstimated(JRCalculator.java:580)     at net.sf.jasperreports.engine.fill.JRCalculator.estimateVariables(JRCalculator.java:179)     at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:787)     at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1482)     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:130)     at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)     at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)     at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)     at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)     at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247)     at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:878)     at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)     at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: java.lang.NumberFormatException: For input string: "X"     at java.lang.NumberFormatException.forInputString(Unknown Source)     at java.lang.Integer.parseInt(Unknown Source)     at java.lang.Integer.valueOf(Unknown Source)     at sun.reflect.GeneratedMethodAccessor817.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)     at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)     at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)     at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)     at DeviceReport_1307053781917_733717.evaluateEstimated(calculator_DeviceReport_1307053781917_733717:489)     at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:246)Â
  5. Ok so I did what you suggested and I discovered that no matter whether the checkbox1 parameter is true or false the expression always ends up executing the "else" block. $P{checkbox1}? "where trans_no='BBT00000195'" : "where trans_no='BBT00000200'" where trans_no='BBT00000200' this always get executed no matter what $P{checkbox1} is.Is this a syntax error ? What else could it be, cause this is as simple of an expression as I can imagine but I just can't figure it out.
  6. OK so after some playing around I figured out that I was doing something dumb and I finally now get how this stuff works. Now I have the following problem. Basically this is what I have: [/code]Unchecking the box gives me all the results in my query with no filtering. BUT if I check the box, I still get all the results, my filter does not work. I am confused as to why that is. Post Edited by teamdebo at 02/28/2011 19:16</pre><table align="center" border="0" cellpadding="3" cellspacing="1" width="90%" style="border-top-color:rgb(211,211,211);border-right-color:rgb(211,211,211);border-bottom-color:rgb(211,211,211);border-left-color:rgb(211,211,211);border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:dotted;border-right-style:dotted;border-bottom-style:dotted;border-left-style:dotted;">Code:[code]$P{checkbox1}? "where trans_no='$P{trans_no_val}'": ""trans_no_val is a string parametercheckbox1 is a boolean parameter</
  7. Sorry for a long time before response I got caught up in other projects. I see what you're saying basically make an if statement inside the parameter. My problem is: can I do something like this MyCheckboxParam ? "where column_x = '$P(param2)'" : "%" basically if the checkbox is checked then I use a user entered string as the "where" filer and if it's not selected then I want to not use the where and return all records.
  8. I have a question I simply can't find any information about. Basically, I need to have a checkbox in my report. If the checkbox is selected then my where clause will use a parameter in the query. If the checkbox is not selected the where clause will not use the parameter. Is that something that can be done? Please if anyone has any suggestions at all, it would be more than helpful. Thank you.
×
×
  • Create New...