Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: cde components using dojo gauge

  1. #1

    Default cde components using dojo gauge

    i'm tryng to implement a cde component using a dojo gauge in pentaho ce 5.1.
    dojo 1.9 is already in pentaho 5.1 and i know that the pentaho 5.1 use requirejs to dinamically load javascript library .
    If i try to use dojo require to load the gauge module i get an error .
    So i tried to use reuquirejs .
    I have put a dependency in the component.xml :


    <Dependencies>
    <Dependency src="../../../../../common-ui/resources/web/dojo/cdeDojoInit.js" version="1.0">cdedojoinit</Dependency>
    </Dependencies>

    the content of cdeDojoInit.js is :

    require.config={
    baseUrl: 'content/common-ui/resources/web/dojo',
    packages: [
    { name: "dojo", location: "dojo", main:'main' },
    { name: "dijit", location: "dijit"},
    { name: "dojox", location: "dojox" }
    ]
    };


    require([
    "dojo/dom",
    "dijit/form/Button",
    "dojox/gauges/GlossyCircularGauge",
    "dojox/gauges/GlossySemiCircularGauge"
    ], function(dom,Button,GlossyCircularGauge,GlossySemiCircularGauge) {
    alert("dojo loaded");
    });

    the script does not report errors when run but dojo was not loaded .
    the variables dom,Button,GlossyCircularGauge,GlossySemiCircularGauge are not inizialized .
    the cde component go in error because dojo and dojox are not defined .
    where am I doing wrong?
    thanks for any answer

  2. #2

    Default

    i have realized that the require function is not defined by the requirejs library but by the js file pen-shim.js .
    so i can't use both the dojo loader ( loaded fom dojo.js ) and the requirejs loader because conflict whit the definition of require and define function in pem-shim.js .
    i think that there is no solution to initialize dojo from a definition of a cde component .
    would be possible to initialize dojo at the startup of a cde dasboard ?
    thanks for any answer

  3. #3
    Join Date
    Mar 2012
    Posts
    645

    Default

    Hi Claudio,

    The platform does include requirejs and dojo through the special webcontext.js resource.
    However, CDF is not currently compatible with it (I think mostly because of jquery versions), and so does not include it.


    Loading dojo and/or requirejs explicitly by defining these as CDF components dependencies won't work also, because these are loaded after the CDF's base files, where pen-shim.js lies.
    So the only way should be to include dojo and/or requirejs before CDF files, by changing the CDF/CDE templates.

    Let me know if it worked.

  4. #4

    Default

    hi duarte ,
    thanks very much for your response .
    i'll try the council you gave me and i'll let you know if it works

    thanks again .

  5. #5

    Default

    in order to load the dojo library before the js file pen-shim.js , i have created a new style and i have included in the header the script tag for the dojo library as follow :

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script language="javascript" type="text/javascript" data-dojo-config="parseOnLoad: true" src="/pentaho/api/repos/pentaho-cdf/js/lib/dojo/dojo/dojo.js"></script>
    @HEADER@
    </head>

    In this way dojo is loaded before the file pen-shim.js but i get several errors because it can not find jquery .
    Solved this porblem it continues to go wrong because the function $ is undefined .
    The real problem was that i must put the script tag of dojo not in the header but in the body .
    If i put the script tag in the body , dojo is loaded after the
    pen-shim.js and it goes wrong .

    i'm very sorry but i'm afraid there is no solution




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.