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

Support for Global Variables?


umair

Recommended Posts

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Try that :

 

<parameter name="LoggedInUser" isForPrompting="true" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User"

 

and after in the definition of a Text Field :

 

$P{LoggedInUser}.getFullName()

 

(extract from French jasperserver forum: answer by Christopher André from Jaspersoft Corporation)

Link to comment
Share on other sites

In iReport, you edit your jrxml code. In the left frame, you add a parameter with name "LoggedInUser", you check the "Use as prompt" box and you put "com.jaspersoft.jasperserver.api.metadata.user.domain.User" in the combo parameter type (perhaps a problem with a class not found but don't care)

 

Then you add in your report a textField and you define its expression definition as "$P{LoggedInUser}.getFullName()"

 

When you run the report, the text field contains the logged user name.

Link to comment
Share on other sites

In iReport, you edit your jrxml code. In the left frame, you add a parameter with name "LoggedInUser", you check the "Use as prompt" box and you put "com.jaspersoft.jasperserver.api.metadata.user.domain.User" in the combo parameter type (perhaps a problem with a class not found but don't care)

 

Then you add in your report a textField and you define its expression definition as "$P{LoggedInUser}.getFullName()"

 

When you run the report, the text field contains the logged user name.

Link to comment
Share on other sites

Heres what i did,

View->Parameters->New

 

ParameterName: LoggedInUser

ClassType: String

UseAsPrompt: checked

 

Applied a Text Field with expression definition as "$P{LoggedInUser}.getFullName()".

Saved the report, uploaded the jrxml file and ran to see the following errors:

 

com.jaspersoft.jasperserver.api.JSExceptionWrapper: Errors were encountered when compiling report expressions class file: 1. The method getFullName() is undefined for the type String value = (java.lang.String)(((java.lang.String)parameter_LoggedInUser.getValue()).getFullName());//$JR_EXPR_ID=12$ <---------> 2. The method getFullName() is undefined for the type String value = (java.lang.String)(((java.lang.String)parameter_LoggedInUser.getValue()).getFullName());//$JR_EXPR_ID=12$ <---------> 3. The method getFullName() is undefined for the type String value = (java.lang.String)(((java.lang.String)parameter_LoggedInUser.getValue()).getFullName());//$JR_EXPR_ID=12$ <---------> 3 errors

com.jaspersoft.jasperserver.api.JSExceptionWrapper: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:

1. The method getFullName() is undefined for the type String

value = (java.lang.String)(((java.lang.String)parameter_LoggedInUser.getValue()).getFullName());//$JR_EXPR_ID=12$

<--------->

2. The method getFullName() is undefined for the type String

value = (java.lang.String)(((java.lang.String)parameter_LoggedInUser.getValue()).getFullName());//$JR_EXPR_ID=12$

<--------->

3. The method getFullName() is undefined for the type String

value = (java.lang.String)(((java.lang.String)parameter_LoggedInUser.getValue()).getFullName());//$JR_EXPR_ID=12$

<--------->

Link to comment
Share on other sites

Umair,

I think your problem comes from the fact you defined the parameter type as "string" and not as "com.jaspersoft.jasperserver.api.metadata.user.domain.User" as said. This is not in the combo list : you must enter it by overwriting in the combo.

In my case, under iReport this class is not defined so you got a "Problem". But it is defined in jasperserver and if you run the report from jasperserver there is no problem. I tested on one report before posting my reply.

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...