|
|
|
|
|
|
JasperServer
 
Forums >  JasperServer Discussion/Help >  Using Jasperserver user login in report  >
   
Go to bottom
  • Page:
  •  1 
JasperServer Discussion/Help Topic:
#69428
Using Jasperserver user login in report 01/10/2010 00:41  

I've read all the entries related to how to use a user login in a report, but I'm missing something.

I've got 3.7 verson of jasperserver and the 3.6 version of iReports.

 

Most of the posts related to this say that you need to create 2 parameters.  In iReports I've created a parameter LoggedInUser and set the Parameter Class to com.jaspersoft.jasperserver.api.metadata.user.domain.User and with a default value expression = Test

Then I create a second parameter UserID and give it a default value expression of $P{LoggedInUser}.getFullName()

The report has only one element - a text field to show the value of UserID.  When compiled I get the error - ClassNotFoundException:  com.jaspersoft.jasperserver.api.metadata.user.domain.User

Can anyone tell me what I'm doing wrong??

Here is the XML -

<?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="LoginNameTest" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
 <parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User" isForPrompting="false">
  <defaultValueExpression><![CDATA[aaa]]></defaultValueExpression>
 </parameter>
 <parameter name="UserID" class="java.lang.String">
  <defaultValueExpression><![CDATA[$P{LoggedInUser}.getFullName()]]></defaultValueExpression>
 </parameter>
 <background>
  <band/>
 </background>
 <title>
  <band height="79"/>
 </title>
 <pageHeader>
  <band height="35"/>
 </pageHeader>
 <columnHeader>
  <band height="61"/>
 </columnHeader>
 <detail>
  <band height="125">
   <textField>
    <reportElement x="247" y="58" width="100" height="20"/>
    <textElement/>
    <textFieldExpression class="java.lang.String"><![CDATA[$P{UserID}.toString()]]></textFieldExpression>
   </textField>
  </band>
 </detail>
 <columnFooter>
  <band height="45"/>
 </columnFooter>
 <pageFooter>
  <band height="54"/>
 </pageFooter>
 <summary>
  <band height="42"/>
 </summary>
</jasperReport>
 

 

dknutson
user photo
Project Roles
Posts: 24
graphgraph
Karma: 4
graphgraph
 
#69430
RE:Using Jasperserver user login in report 01/10/2010 05:44  

Hello,

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

exists only on the server so if you try to compile your report only with iReport this will not work.

Try to upload your report in the server and then run it from the server.

Hope this helps,

Guillaume



Post Edited by gautier at 01/10/2010 05:45
gautier
user photo
Project Roles
Posts: 25
graphgraph
Karma: 6
graphgraph
 
#69434
RE:Using Jasperserver user login in report 01/10/2010 17:24  
Thanks for the reply. I was thinking that if I copy the correct jar to the iReports lib folder, then set LoggedInUser with a default, it should work. Problem is I'm not sure of which jar and where to put it - iReports or Java folder
dknutson
user photo
Project Roles
Posts: 24
graphgraph
Karma: 4
graphgraph
 
#69442
RE:Using Jasperserver user login in report 01/11/2010 09:52  
On a side note, I have switched to using:
<parameter name="LoggedInUsername" class="java.lang.String" isForPrompting="false"/>

This eliminates one parameter in order to get the user name, and I have experienced it to be a more stable solution.
msn
user photo
Project Roles
Posts: 8
graphgraph
Karma: 5
graphgraph
 
#69456
RE:Using Jasperserver user login in report 01/11/2010 16:10  
How exactly are you useing "LoggedInUsername" and what do you mean by eliminates one parameter?
I've tried using it by itself setup as you describe and it come up null. I've gotten it to work where LoggedInUsername references a second parameter containing LoggedInUser.getUserName(), but at this time I can't get the parameter to work in a query.
dknutson
user photo
Project Roles
Posts: 24
graphgraph
Karma: 4
graphgraph
 
#69459
RE:Using Jasperserver user login in report 01/11/2010 16:29  

I have only tried this with JasperServer 3.5.0, but the only thing you have to do, is in iReport to add a parameter of type String which is called "LoggedInUsername" (and that's the name reserved by JasperReport). This should correspond to manually adding the jrxml as listed in my last reply.

Come to think about it, the LoggedInUsername gives you the login name of the user currently logged in to the JasperServer, and not the attached Full Name field of this Jasper user account.
However, if the username (not the full name) would suffice, for me having the LoggedInUsername as String parameter replaced the need for having both the "LoggedInUser" parameter and the second parameter with default value $P{LoggedInUser}.getUsername().

I think perhaps "LoggedInUserFullName" exists as well. Also a String parameter that Jasper provides automatically without any input control.



Post Edited by msn at 01/11/2010 16:30
msn
user photo
Project Roles
Posts: 8
graphgraph
Karma: 5
graphgraph
 
#69460
RE:Using Jasperserver user login in report 01/11/2010 16:33  
Thanks - that clears up something. A few months back I tried this with 3.5 and had no problems. With 3.7 it doesn't work. I think I'll reload 3.5.
dknutson
user photo
Project Roles
Posts: 24
graphgraph
Karma: 4
graphgraph
 
#69471
RE:Using Jasperserver user login in report 01/11/2010 22:15  
I just loaded up a 3.5 Jasperserver and tested this. I logged in as userid = DMKTest. It's giving me the current default for LoggedInUsername "DMK" not the userid. Any idea why?
dknutson
user photo
Project Roles
Posts: 24
graphgraph
Karma: 4
graphgraph
 
#72222
RE:Using Jasperserver user login in report 03/21/2010 18:36  

The parameters available are defined on this wiki page: http://jasperforge.org/plugins/mwiki/index.php/Jasperserver/Cascading_input_controls

 

@dknutson:  I don't know why you are not getting the right value. It works in general for other folks.

 

Sherman

Jaspersoft

swood
user photo
Project Roles
Project Owner,Project Admin,Project Admin,SCM Committer
Posts: 1944
graphgraph
Karma: 192
graphgraph
 
Go to top
  • Page:
  • 1
 
 
JasperForge Quotes
"I am running JasperReports and they are fantastic! I love iReport. I think it's a great very professional job. JasperReports and iReport are very cool. Nice work."
 
Founding Member, Open Solutions Alliance       Hot Jasper Projects on SOURCEFORGE.NET       Powered by EssentiaESP