Jump to content
  • Accessing jsquery.js for custom UI pages starting from JasperReports® Server v8.0.0


    vchiem
    • Features: JasperReports Server Version: v8.0.0 Product: JasperReports® Server

    Issue:

    We have some customized UI pages that rely on jQuery. 

    With JasperReports® Server v7.5, the variable "jQuery" is available and usable to our JavaScript but this is no longer the case with JasperReports® Server v8.0.0.

    For example, our custom pages include open-source JavaScript libraries like DataTables.net that rely on jQuery.

    How can we access jQuery using JasperReports® Server 8.0.0?

     


     

    Solution:

    Starting with JasperReports® Server v8.0.0 the libraries used by JasperReports® Server will not be exposed to the global scope. 

    Because of this, an attempt to use jQuery from the global scope will not work unless jQuery is added to the global scope by your custom code.

    Use DOM API instead. In JSP where your JavaScript code is, replace:

    jQuery(document).on("controls:initialized", function(event, controlsViewModel) {

    with

    document.addEventListener("controls:initialized", function(event, others) {    
        var controlsViewModel = event.detail;

    However, if you need access to jQuery.js you can include it in your JSP with a script tag like below:

    <script src="${pageContext.request.contextPath}/scripts/jquery.js"></script>

    If you need it for multiple pages you can include it in decoratorMinimalImports.jsp

    You also need to place your own copy of jquery.js into your scripts folder.

     


    Related Articles:

    https://community.jaspersoft.com/questions/1191911/jasper-server-800-custom-input-controls-not-working-jquery-not-loading


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