Jump to content

get iReport Params from jasperserver user session


kmansfield

Recommended Posts

I would like to store objects in the jasper server HTTP User session and then be able to retrieve them for use by IReport parameters. Are there any mechanisms in jasperserver and iReports to accomplish this? Another idea is just write my own cache implementation to retrieve at report generation, although I didn't see a way to get specific user id via iReport Parameters?

 

Are there any other recommendations?

 

Background: I have some customized acegi authentication mechanisms that authenticates and loads user info from another server once upon login and this info will be used in report generation for displaying and filtering of data. We are a reseller so company id and name are used to filter data appropriately and for displaying reports with company specific data. Also, these parameters should not be set or seen by the user to ensure user doesn't have access to another companies' data.

 

Thanks,

 

Keith

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

kmansfield wrote:

I would like to store objects in the jasper server HTTP User session and then be able to retrieve them for use by IReport parameters. Are there any mechanisms in jasperserver and iReports to accomplish this? Another idea is just write my own cache implementation to retrieve at report generation, although I didn't see a way to get specific user id via iReport Parameters?

 

In JasperServer, check out this sample file:

 

/Reports/Samples/Sales by Month Report

 

It includes a parameter named LoggedInUser. Its Parameter Class Type is:

 

com.jaspersoft.jasperserver.api.metadata.user.domain.User

 

Are there any other recommendations?

 

If the above does not work for you, I suppose you could define a parameter using iReport (string) and map it to an Input Control in JasperServer (text). You would then programmatically pass it from your app to the report. But I think the above should work for you...

 

Background: I have some customized acegi authentication mechanisms that authenticates and loads user info from another server once upon login and this info will be used in report generation for displaying and filtering of data. We are a reseller so company id and name are used to filter data appropriately and for displaying reports with company specific data. Also, these parameters should not be set or seen by the user to ensure user doesn't have access to another companies' data.

Thanks,

Keith

 

If you use the parameter with class type com.jaspersoft.jasperserver.api.metadata.user.domain.User, there is no server-side Input Control, and as far as I can tell, the user does not see it.

 

If you create an Input Control in JasperServer, then you'll want to de-select the "Visible" checkbox.

 

Hope this helps. BTW, I'll join Matt Dahlman for a webinar on Wednesday morning (10 am PDT) to go through parameters. We'll cover both basic and advanced topics, and may touch on your question. Here's the abstract for the session: http://www.jaspersoft.com/nw_events.html

 

Link to comment
Share on other sites

  • 2 months later...

Thanks for everyone's help. The Sales by Month Report was a good example at accessing jasperserver's user session information.

 

On the custom session parameter front, what I did was to implement my own user session cache and during authentication in our custom acegi provider, the parameters are set into the cache with the username being the key to the cache. The reports then use the jasperserver user object to retrieve the username and then reference the singleton user session cache using the username to get the custom parameters. I implemented the user session cache with some custom code and ehcache and placed it into a custom jar that I deploy to jasper's WEB-INF/lib directory.

 

I also created a stub, pre-populated users session cache so that developers can easily test these custom parameters in i-report developer studio outside of jasperserver. Out of container the stub gets instantiated and in container the real version is instantiated.

 

Going forward, we may change the implementation to extend Jasper's User object to hold the parameters instead of using the custom user session cache, but this is a more invasive customization.

Link to comment
Share on other sites

  • 5 years later...

Hi mmflynn,

 

As above mentioned,

 

"Background: I have some customized acegi authentication mechanisms that authenticates and loads user info from another server once upon login and this info will be used in report generation for displaying and filtering of data. We are a reseller so company id and name are used to filter data appropriately and for displaying reports with company specific data. Also, these parameters should not be set or seen by the user to ensure user doesn't have access to another companies' data."

 

I need to do same scenario can u explain how to do in jasperserver.

 

Link to comment
Share on other sites

  • 1 month later...

Hi ,

I have created iReport based report. which would display simple logged in username parameter value. please find below jrxml file. when i run this report in server, i am getting empty report. I am not getting loggedinusername. please advice me is there anything i am missing here. thanks in advance.

<?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="report7" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c1202fd9-44f4-42c6-a3c2-45c21bc60347">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User" isForPrompting="false"/>
<parameter name="Username" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[$P{LoggedInUser}.getUsername()]]></defaultValueExpression>
</parameter>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="76">
<textField>
<reportElement uuid="b128f89e-0122-47be-a02e-e76026359414" x="22" y="21" width="364" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$P{Username}]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="50">
<staticText>
<reportElement uuid="6749d95a-5d66-49af-840a-d3afb0347883" x="268" y="26" width="100" height="20"/>
<textElement/>
<text><![CDATA[Test]]></text>
</staticText>
</band>
</columnHeader>
<summary>
<band height="130" splitType="Stretch">
<staticText>
<reportElement uuid="4a30d70a-23b5-4fa1-a80f-c2add14714d2" x="240" y="42" width="100" height="20"/>
<textElement/>
<text><![CDATA[Test]]></text>
</staticText>
</band>
</summary>
</jasperReport>
is there anything i am missing. still my report is empty.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...