Jump to content
  • How to use built in parameter (LoggedInUser) in report and scriptlet


    Friendly User
    • Features: Parameters Version: v5.6, v5.6.2, v5.6.1, v5.6.0, v5.5, v5.5.2, v5.5.1, v5.5.0, v5.3, v5.3.0, v5.2, v5.2.0, v5.1, v5.1.2, v5.1.0, v5.0, v5.0.4, v5.0.3, v5.0.2, v5.0.1, v5.0.0 Product: JasperReports® Server

    This article is NO LONGER VALID in versions 6.x and beyond

    Issue

    How we can use built in parameters?

    Please give some example of using built in parameter (LoggedInUser).

    We want to use "LoggedInUser" in query and in scriptlet class.

    Resolution

    To use LoggedInUser parameter you need to first define it in your report like this:

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

    Now you can use the parameter in same fashion as you use parameters and can access methods of this object like this:

    $P{LoggedInUser}.getRoles()
    

    You can check the list of parameters in chapter 4.4 - Built-in Parameters for Query-based Input Controls of JasperReports Server Administrator Guide.

    For list of methods you should refer to our javadoc (Jasperserver-ce public API), specifically User class. In scriptlet you'll have to call this method:

    public java.lang.Object getParameterValue(java.lang.String parameterName, boolean mustBeDeclared) throws JRScriptletException
    

    To get the User object from parameter and then you'll be able to use it's methods.

    More info on scriptlet methods can be also found in public API here:

    http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRAbstractScriptlet.html


    Ref. Case #00024935 -- 16:42, 26 June 2012 (UTC)

    See Also


    User Feedback

    Recommended Comments

    There are no comments to display.



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