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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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

jduprez
echo your command line before executing it, and check whether it is actually the same. For example, I'm not profcient with Shell, but are you sure that
\'
is really the escape sequence for
"{code} ?                                                                                                                                                                                                                                                                                                                                                                                                                                                        
tschodt
jduprez wrote:
echo your command line before executing it, and check whether it is actually the same. For example,
I'm not proficient with Shell, but are you sure that
\'
is really the escape sequence for
"{code} ?
Spot on.
But the shell does not care, it will be java that barfs on {code}\'{code}
Use one of
$ _VM_PROPERTIES='-Djava.library.path="lwjgl/native/linux"'
$ _VM_PROPERTIES="-Djava.library.path=\"lwjgl/native/linux\""
796440
jduprez wrote:
echo your command line before executing it, and check whether it is actually the same. For example, I'm not profcient with Shell, but are you sure that
I usually add -xv to the /bin/bash line so that the shell dumps out all kinds of trace info as it executes.
jduprez
echo your command line before executing it, and check whether it is actually the same. For example, I'm not profcient with Shell, but are you sure that
I usually add -xv to the /bin/bash line so that the shell dumps out all kinds of trace info as it executes.
Thanks for the tip! ;)
839862
Thanks for the replies guys/gals.

I have modified the script and echoed my command that should be running under the shell script, it is:
java -classpath WcgFramework.jar:WcgPocSwordplay.jar:log4j-1.2.16.jar:jme/jme-colladabinding.jar:jme-audio.jar:jme-awt.jar:jme-collada.jar:jme-editors.jar:jme-effects.jar:jme-font.jar:jme-gamestates.jar:jme-model.jar:jme-ogrexml.jar:jme-scene.jar:jme-swt.jar:jme-terrain.jar:jme.jar:jogl/gluegen-rt.jar:jogl/jogl.jar:jorbis/jorbis-0.0.17.jar:junit/junit-4.1.jar:lwjgl/jinput.jar:lwjgl/lwjgl.jar:lwjgl/lwjgl_util.jar:lwjgl/lwjgl_util_applet.jar:swt/windows/swt.jar:jbullet/jbullet-jme.jar:jbullet/asm-all-3.1.jar:jbullet/jbullet.jar:jbullet/stack-alloc.jar:jbullet/vecmath.jar:trove-2.1.0.jar:sceneMonitor/jmejtree_jme2.jar:sceneMonitor/propertytable.jar:sceneMonitor/scenemonitor_jme2.jar:sceneMonitor/sm_properties_jme2.jar -Djava.library.path="lwjgl/native/linux" -Xmx1024m -Xms768m -ea com.mygame.Main
I am more confident that now the shell script should be fine (I am a shell script noob) because this very command if I copy from terminal and paste into the terminal, runs the application no problem at all. But I am amazed that it is still not working. I must be doing something obviously wrong. :-(

I used the code as suggested:
_VM_PROPERTIES='-Djava.library.path="lwjgl/native/linux"'
I am stumped!? :-(

Thanks for help.
796440
So, some command works just fine when entered into a terminal, but when run inside a shell script, the exact same command fails?

Then obviously, something is different between the terminal environment and the shell environment. Here are a few things you can try.

1. In both the terminal and the shell, execute the set command (or shell builtin). It should tell you all the environment variables, aliases, and shell functions.

2. Try adding -xv after #!/bin/bash to see details about what the script is doing.

3. In a terminal window, try sourcing the shell script. That is, type source whatever.bash. Does that work?

When the script fails, does it fail both when executing from a terminal and from within Java? Or just in Java/

4. Try executing the script as a login shell. I think adding -l to /bin/bash does that, but check the man page to be sure. I wouldn't recommend this as a permanent solution, just to see if it makes a difference. If so, then there's a difference between your login shell and a shell executed from within Java, so you can pursue that lead.
jduprez
jverd wrote:
When the script fails, does it fail both when executing from a terminal and from within Java? Or just in Java/
4. (...) difference between your login shell and a shell executed from within Java, so you can pursue that lead
Hello Joanna Verd (since myself am a guy, I guess the "gal" must be you) :o)

You seem to infer the OP is reporting a problem with exec'ing a Java program from a Java program. I don't read anything that supports this in either of the OP's posts... I only read his issue as "difference between shell script and interactive shell" - which I acknowledge you addressed too.

Regards,

J.
839862
I have solved the problem:

The line:
_VM_PROPERTIES='-Djava.library.path="lwjgl/native/linux"'
should be:
_VM_PROPERTIES=-Djava.library.path="lwjgl/native/linux"
(without the single quotes) and this works fine and starts up all good via the shell script and command line.

Thanks for all your help and suggestions.

Riz
1 - 8

Post Details

Added on Apr 22 2019
3 comments
877 views