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

rault

Members
  • Posts

    19
  • Joined

  • Last visited

rault'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. Excellent write up! Thanks for coming back and posting it.
  2. Sounds like you are just starting out. Let's say you add an input control with an ID of MY_INPUT_CONTROL. You'll then need to create a parameter with the name "MY_INPUT_CONTROL". Jasper somehow figures out that these two match up. Then, in the default expression for the parameter I think you can just put "new Date()" if you are using the single input control with a Date data type. Even if your input control is a type of Text, you should be able to put "new Date().toString()" as the default expression. Since Jasper matches up your parameter and your input control, your input control will get the value of the default expresison. Hope that makes sense, but that's how it works. Post Edited by rault at 04/23/2012 20:28
  3. Kudos for finding the solution. Just wait to to find out the order in which parameters are defined in the XML matters but the UI orders them alphabetically. Or the need for a dummy group to get grand totals to display just below the detail band. I can send you some of my hair that I've pulled out. :P
  4. This is a sore point with me. I've asked Jasper about this and while they have improved things int their app its still not a good experience. What they've told me is to create an organization and a custom theme for mobile and apply the custom theme then when you are using a tablet or phone you login to the Mobile organization. While I'm sure that would work there is no reference or resource for a custom theme like that and I'd have to start from scratch to create it. Way too much work for one guy that isn't steeped in daily CSS. "I'm a developer, not a miracle worker Jim!"
  5. Take a look at the actionModel-search.xml and applicationContext-search-pro.xml files in the WEB-INF directory. You can see the menu items are broken up by XML by role. I wonder if you could modify that or define your own section based on role. Depends on whether those are hard coded to the built in roles Jasper uses...give it a try and be sure to restart Jasper afte you make changes so they get picked up by the application. We commented out the menu items for the features we aren't using. If you try it and it works, come back and post. I'm curious if it would... Post Edited by rault at 04/23/2012 20:11
  6. True, I think the syntax is: $X{IN, TableFieldName, CollectionParameterName} I had a case where I was passing a Collection in a hyperlink and the items in the hyperlink contained commas. Since the Collection gets turned into a string for the query string parameter the drill through report was picking it up and creating the wrong items. Let's take a simple example, let's say I have a Collection with a single item in it like so: [Joe's Crab Shack, LLC] The field in the report is a hyperlink on Joe's Crab Shack, LLC to a second report that shows sales detail. What we should be doing is passing the IDs of the records but in our database we have names that come from locations and a "global" name that each name gets grouped together as. Normally I would have put the global name in its own table but I wasn't the one that designed the database and I don't think "we" can change it anytime soon, if at all. So the hyperlink parameter comes over in the querystring like: http://mydomainname.com/whatever/flowwhatever?reportid=whatever&MYCOLLECTION=[Joe's Crab Shack, LLC] The second report picks up the value for the collection and because it seems to be using the built in parser from Java (I'm guessing about that...) it causes the Colelction to contain two items like so: [Joe's Crab Shack, LLC] Item1 = Joe's Crab Shack Item2 = LLC Which is no longer the item I was trying to send over on the drill thorugh. But it's true, in most cases using the $X{IN} is better because you don't have to think about it. Using the spring framework method, you can choose what delimiter to use on your own: org.springframework.util.StringUtils.collectionToDelimitedString($P{MyCollection}, "MYDELIMITER") Which can be a poundsign "#" or a combination of unique charaters "#!#". Whatever will work with the data you are passing. In the MYCOLLECTION parameter in the second report you can use the Collection.join method to convert it back into a Collection. I bet Jasper is doing this, but using the built in toString() method for Collections which has a comma delimiter built in. The best method though would be to pass IDs and just use $X{IN} but that just doesn't work for me in this case. Post Edited by rault at 04/23/2012 19:57
  7. I have been using iReport 4.0.1 and publishing reports to Jasperserver 4.2.0. In all of my reports I have this parameter so I can get the users name: <parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User"/> I installed Jaspersoft Studio 1.0.9, connected to my respository, opened a report, made a small change and tried to publish back to the server but I recieve this error: net.sf.jasperreports.engine.JRRuntimeException: java.lang.ClassNotFoundException: com.jaspersoft.jasperserver.api.metadata.user.domain.User Obviously some reference to the class is missing but I'm at a loss to understand where and what to do to fix it. Any ideas?
  8. Not sure "mod" is quite right...from the iReport guide on how to do alternating row color: The trick is pretty simple. The first step is to add a frame element in the detail band. The frame will contain all the elements of the band, so we are using the frame asif it were the background for the band itself; in fact, the frame should take all the space available in the band. Then all the textfields will be placed inside the frame. First we define a new style (let's call it Style1). We will keep all the default values, since we are not interested in changing them when the row number is odd (1, 3, 5, etc...). Now we add a conditional style and set as the condition the expression: ($V{REPORT_COUNT} % 2) == 0 Remember, we have been using Groovy or JavaScript as the report language. In Java the expression would be a bit more complicated, for example: ($V{REPORT_COUNT}.intValue() % 2) == 0 What the expression does is calculate the rest of the set by 2 (the operator % has this function), and we check if the remainder is 0. If it is, the current record (held by the REPORT_COUNT built-in variable) is even and we use the conditional style Style1For this style, we set the background property to a light gray (or any other color of our choice) and the opaque property to true (otherwise the previous property will not take effect). Finally, we apply the style to the frame elementby selecting theframe and setting the style property to Style1.
  9. This could also be caused from a detail band being too tall. Or, does the column footer band always render at the bottom of the page? That might be it. I don't know...maybe that's page footer I'm thinking of. Maybe you could create a dummy group and put the value in the group footer then delete the group header band, maybe set the report execution to Report on the textfield if its a sum over all the data.
  10. ...and create dummy test reports and only work on one specific thing at a time. I find its harder to test some new logic or new way of doing things in an existing report. Make a blank report with a query like: select 'nothing' as nothing Then create your parameters and figure out how the ternary operators work, or try injecting a single value and seeing it in the report. select '$P{MyParameter}' as nothing ..and make the value of MyParameter "something". Then refer to the "nothing" column in a textfield expression to see it in the report. Start small and work your way into the more complicated things.
  11. Found a better solution and posted it here: http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=95869
  12. This can be done but you'll need to do some dynamic SQL and you'll need many parameters to do it. You can inject SQL into a query by adding an exclamation point after the P in a query. For example you have a parameter like this in your query: $P{ParameterName} ...which Jasper thinks is a parameter and passes a value for the engine to evaluate. That's not what you want. What you need to do is add "!" like so: $P!{ParameterName} Now you can drop that in your query and it will evaluate it in the query before the query is sent to the database server. Take this for example: SELECT * FROM $P!{ParameterName} Let's say the value of $P{ParameterName} can be either 30MAR12_A or 30MAR12_B based on the time of day or what you select from an input control for the report. In this case we'll say it is 30MAR12_B. Jasper will figure out what that is and send the query to the data base like so: SELECT * FROM 30MAR12_B Now let's say you have a second parameter called $P!{ParameterName2} that has a value of: "join 30MAR12_C on 30MAR12_C.ID = 30MAR12_B.ID" You can then use a ternary operator to inject (or not) that join. The ternary operator syntax looks like: ( <condition> ? exp1 : exp2 ) You could use the Date or Calendar object with SimpleDateFormat to get the "30MAR12" part of the table name. Combining these concepts the expression for ParameterName2 could be something like: ( $P{SomeValue}=="whatever" ? "join " + $P{TableName} + "_C on " + $P{TableName} + "_C.ID = " + $P{TableName} + "_B.ID" : "" ) Putting this in the query like so allows you to dynamically join to those tables: SELECT * FROM $P!{ParameterName} $P!{ParameterName2} Let's say the conditoin in the ternary operator was true, the query would be sent to the database like this: SELECT * FROM 30MAR12_B join 30MAR12_C on 30MAR12_C.ID = 30MAR12_B.ID If the condition were false then the value of "", a blank string would be injected like so: SELECT * FROM 30MAR12_B ...hope that's enough to get you started. :)
  13. Put all your charts or all your detail in a subreport then add a subreport element to your group band. This makes the report more complicated overall but I can't see any way around it. You'll needto read the subreports section in the iReport ultimate guide to see how this is done. Do a test report and make something simple. You can pass parameter values from the main report to the subreport if you have input controls. There's a parameter map property of the subreport element to do this. Or you can edit the XML. Post Edited by rault at 04/03/2012 18:20
  14. 1&2) Create a parameter with a name that is identical to the ID of the input control. Get the value, in your example, let's say its "PW" and swap out the column reference in your SQL query. For example: Parameters: Name: InputControlID, used to grab the value from your drop down list (PW, CW, GW) Name: InputControlID_SQL, used for dynamic SQL to swap out column references Query: SELECT S.No, $P!{InputControlID_SQL} as Field2, sum(Charge) as Charge, sum(Duration) as Duration from whatevertablename group by S.No, $P!{InputControlID_SQL} Now for the Default Expression in the InputControlID_SQL parameter, you'll want to nest ternary staements like so: ( $P{InputControlID}=="CW" ? "fieldnameintableforcallwise" : ( $P{InputControlID}=="GW" ? "fieldnameintableforgeographicalwise" : "fieldnameintableforpackagewise" ) ) The first line tests for what was selected in the input control "CW" and the "" value after ? is the name of the field for Call Wise values if the condition in the first line is TRUE, what comes after : is what you do if the condition is false. Look in the Expression Editor in iReport and click on the "User Defined Expressions" item in the list on the left. There's this guy that's displayed on the right: ( <condition> ? exp1 : exp2 ) That's the ternary operator syntax that you use. <condition> is what you test for, exp1 is what the value of the parameter will be if true, and exp2 is the value of the parameter when the <condition> is false. Like I've shown, you can nest this syntax so if something isn't true, you can check for another value. One more thing to point out...if you drag and drop a parameter from the list on the right in the Report Query window into your query, it will look like this: $P{MyParameterName} Leaving it this way will make Jasper pass in the value of the parameter into your query, which is what you want to do in most cases. But when you want to inject SQL you have to tell Jasper to evaluate the string value of the parameter and shove it into the query as if you had written it yourself. To do that you add an exclamation point after the P, like so: $P!{MyParameterName} I hope that helps but my best recommendation is to first read the iReport guide: https://www.jaspersoft.com/store/ireport-ultimate-guide-documentation ...and maybe get some training from Jaspersoft. I don't work for them, I've had to muddle my way through figuring this stuff out, I know its tough when you are just starting out. Good luck. Post Edited by rault at 04/03/2012 17:36
  15. In iReport, create a parameter called "LoggedInUser" with a type (Value Expression) of "com.jaspersoft.jasperserver.api.metadata.user.domain.User". If you use the iReport UI you can paste that into the Value Expression text box. Or you can edit the XML and paste this in: <parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User"/> Then create another parameter called "LoggedInUsername" with the Value Expression "Text" (which is really "java.lang.String" behind the scenes). In the Default Value Expression box, paste this expression in "$P{LoggedInUser}.getUsername()". Or you can edit the XML and paste this AFTER (meaning BELOW) the first parameter (order of operation matters when you create or refer to parameters): <parameter name="LoggedInUsername" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA[$P{LoggedInUser}.getUsername()]]></defaultValueExpression> </parameter> You can then use the LoggedInUsername parameter in a textfield in the report to show the users name. Post Edited by rault at 04/03/2012 16:02 Post Edited by rault at 04/03/2012 18:11 Post Edited by rault at 04/03/2012 18:13
×
×
  • Create New...