Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Not able to populate data from REST using Oracle JET Common Model

Ashish AwasthiApr 22 2019 — edited May 24 2019

Hello Everyone

I am trying to populate a JET table using Common Model and I have followed the approach suggested in JET MOOC Course but my table shows 'Initializing' and there is no error on browser console.

jet table.JPG

Here goes the code of EmpFactory.js file

define(['ojs/ojcore','ojs/ojmodel'], function (oj) {

var EmpFactory = {

    resourceUrl : '[https://codepen.io/cliffsanchez/pen/pbKmEy.html](https://codepen.io/cliffsanchez/pen/pbKmEy.html)', 

    // Single Employee Model

    createEmpModel : function () {

        var emp = oj.Model.extend( {

            urlRoot : this.resourceUrl, 

            idAttribute : "DepartmentId"

        });

        return new emp();

    },

    // Employees Collection

    createEmployeesCollection : function () {

        var employees = oj.Collection.extend( {

            url : this.resourceUrl, 

            model : this.createEmpModel()

        });

        return new employees();

    }

};

return EmpFactory;

});

dashboard.js

/*

* Your dashboard ViewModel code goes here

*/

define(['ojs/ojcore', 'knockout', 'EmpFactory', 'ojs/ojtable','ojs/ojcollectiontabledatasource'],

function (oj, ko, EmpFactory) {

var DashboardViewModel = {

    empCollection : EmpFactory.createEmployeesCollection(), 

    datasource : ko.observable(), 

    // Called each time the view is shown to the user:

    initialize : function () {

        this.datasource(new oj.CollectionTableDataSource(this.empCollection));

        this.empCollection.fetch();

    }

};

return DashboardViewModel;

});

and dashboard.html

<div class="oj-hybrid-padding">

\<h1>Dashboard Content Area\</h1>

\<div id="div1">

    \<oj-table id="table" summary="Department List" 

    aria-label="Departments Table" 

    data='\[\[datasource\]\]'

              columns='\[{"headerText": "Department Id",

              "field": "DepartmentId"},

              {"headerText": "Department Name",

              "field": "DepartmentName"},

              {"headerText": "Location Id",

              "field": "LocationId"},

              {"headerText": "Manager Id",

              "field": "ManagerId"}\]'>

    \</oj-table>

\</div>

</div>

Please let me know where I am doing wrong.

Thanks

This post has been answered by Geertjan-Oracle on May 8 2019
Jump to Answer

Comments

Christian Neumueller-Oracle
Answer

Hi Tim,

the parser for supporting objects which splits a clob into runnable statements is rather simplistic. A "/" on a single line ends the statement. For example, you could use the multi line code pattern of the APEX export files:

c_pkg_spec_script constant t_max_vc2 := apex_string.join(apex_t_varchar2 (

    'CREATE OR REPLACE PACKAGE #PKG_NAME#',

    'AS',

    '  #FUNC_PROC#',

    'END #PKG_NAME#;',

    '/' ));

Since this is about code generation, I sometimes also write templates like this to get consistent alignment and have the template stand out:

c_pkg_spec_script constant t_max_vc2 := regexp_replace(q'[

  % CREATE OR REPLACE PACKAGE #PKG_NAME#

  % AS

  %   #FUNC_PROC#

  % END #PKG_NAME#;

  % /

  ]',

  '^\s+% ', null, 1, 0, 'm' );

Regards,

Christian

Marked as Answer by Tim Halbach · Sep 27 2020
Tim Halbach

Hi Christian,

Thank you so much for that, that's exactly what I was looking for.

1 - 2

Post Details

Added on Apr 22 2019
3 comments
929 views