MohanRao Posted November 7, 2006 Share Posted November 7, 2006 Hello, I got started with JasperIntelligence reports. I am able to work with the formats, groups, totals etc... But I would like to know is there any option of displaying the user_name(the person who has created the report) on the report. If anyone has worked with it, please give an example. Thanks in advance,Mohan Link to comment Share on other sites More sharing options...
swood Posted November 8, 2006 Share Posted November 8, 2006 In your JRXML that will run in JasperIntelligence, add: <parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User"/> All reports get passed this parameter. From this LoggedInUser object you can get: Code: public String getUsername(); public String getFullName(); public String getEmailAddress(); public boolean isExternallyDefined(); public boolean isEnabled(); public Set getRoles(); ShermanJasperSoft Link to comment Share on other sites More sharing options...
MohanRao Posted November 8, 2006 Author Share Posted November 8, 2006 Hello Sherman, Thanks a lot for the solution. I am getting the user name displayed in the JasperIntelligence environment. But when I export the same report to html or pdf formats, I am not able to get the username on the report which is in html or pdf format. Can I get the user name displayed on the corresponding html or pdf? Please can you give some solution for this? Thank you so much,Mohan. swood wrote:In your JRXML that will run in JasperIntelligence, add:<parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User"/>All reports get passed this parameter.From this LoggedInUser object you can get:Code: public String getUsername(); public String getFullName(); public String getEmailAddress(); public boolean isExternallyDefined(); public boolean isEnabled(); public Set getRoles(); ShermanJasperSoft Link to comment Share on other sites More sharing options...
swood Posted November 8, 2006 Share Posted November 8, 2006 Our unit tests export the user name to all formats. Does your report fail? Or just come up with a blank user? In the JRXML, we do things like: Code:<textFieldExpression class="java.lang.String">msg("{0}", $P{LoggedInUser}.getFullName())</textFieldExpression> ShermanJasperSoft Link to comment Share on other sites More sharing options...
MohanRao Posted November 13, 2006 Author Share Posted November 13, 2006 Hello Sherman, I tried the putting the piece of code you had sent. For me it didn't work. My be I was wrong some where. So can you please suggest me more elaborately about how to get the user_name on the report. Iam getting it in the JasperIntelligence environment. But after exporting the same report to pdf, html,... Iam not able to get that. Can you please help me in more detailed manner, please? Thank you,Mohan. swood wrote:Our unit tests export the user name to all formats.Does your report fail? Or just come up with a blank user? In the JRXML, we do things like:Code:<textFieldExpression class="java.lang.String">msg("{0}", $P{LoggedInUser}.getFullName())</textFieldExpression> ShermanJasperSoft Link to comment Share on other sites More sharing options...
swood Posted November 15, 2006 Share Posted November 15, 2006 You are not giving enough information here. As I asked: "Does your report fail? Or just come up with a blank user?" ShermanJasperSoft Link to comment Share on other sites More sharing options...
MohanRao Posted November 15, 2006 Author Share Posted November 15, 2006 The report fails here. I changed the JRXML file the same way as you have suggested. There might be something wrong from my side. I am not able to make out. The error is: it.businesslogic.ireport.ReportClassLoader@1757423 net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. com.jaspersoft.jasperserver.api.metadata.user.domain.User cannot be resolved to a type value = (java.lang.String)(msg("{0}", ((com.jaspersoft.jasperserver.api.metadata.user.domain.User)parameter_LoggedInUser.getValue()).getFullName())); <-------------------------------------------------------> 2. com.jaspersoft.jasperserver.api.metadata.user.domain.User cannot be resolved to a type value = (java.lang.String)(msg("{0}", ((com.jaspersoft.jasperserver.api.metadata.user.domain.User)parameter_LoggedInUser.getValue()).getFullName())); <-------------------------------------------------------> 3. com.jaspersoft.jasperserver.api.metadata.user.domain.User cannot be resolved to a type value = (java.lang.String)(msg("{0}", ((com.jaspersoft.jasperserver.api.metadata.user.domain.User)parameter_LoggedInUser.getValue()).getFullName())); <-------------------------------------------------------> 3 errors swood wrote:You are not giving enough information here.As I asked: "Does your report fail? Or just come up with a blank user?"ShermanJasperSoft Link to comment Share on other sites More sharing options...
swood Posted November 17, 2006 Share Posted November 17, 2006 So the report does not compile in iReport. If you want to do this, you will need to get the jasperserver-api-metadata-XXX.jar and probably jasperserver-api-common-XXX.jar from the server and include it in the iReport classpath. That should allow the report to compile. It will not run and produce a report in standalone iReport, as that parameter will come from the server at runtime. You can use the iReport JasperIntelligence plugin to publish the report through the server, or use the server maintenance screens to create a report unit using this JRXML. ShermanJasperSoft Link to comment Share on other sites More sharing options...
emiii0 Posted September 24, 2009 Share Posted September 24, 2009 Whenever I try to do this, I always get 'null' as a value. I only have JasperServer installed and not the Intelligence Suite. Does this only work if I install the entire suite?For testing I have the parameter set to display in the title section. Code: Post Edited by emiii0 at 09/24/2009 15:48Post Edited by emiii0 at 09/24/2009 15:49 Link to comment Share on other sites More sharing options...
mdahlman Posted September 24, 2009 Share Posted September 24, 2009 emiii0, Yes, JasperServer is all you need. Please start a new thread, as the details of whatever is causing the problem are likely to have changed since the main thread 3 years ago. For troubleshooting purposes, please post a minimal .jrxml file that just shows the problem (without the additional crosstab). Regards,Matt Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now