I will show in the post, how you can show a Table with Rest Service data in Oracle JET.
As I Explained in this post: https://mydevelopertools.blogspot.cl/2017/11/run-oracle-jet-application-in-weblogic.html, we can create an ADF application and put in public_html folder the Web content of Oracle JET application and run it on Weblogic. I'll use this ADF application to create a project to my Rest services and consume it on Oracle Jet App.
In your Model project create a new view object with two or three attributes and put this VO on Application Module
In Application Module, navigate to web Services -> tab Rest and add a new Rest Resource on Add icon and name it. Click Ok, and it will create a Rest Web service project.
Run Project and test it on browser
Now, I'll create Jet app and we should use the Oracle JET QuickStart template to create a basic App, more details in this post: https://mydevelopertools.blogspot.cl/2017/11/oracle-jet-first-touch.html
To call a Rest Service: Navigate to Site Root/ViewsModels - create/edit customers.js file and paste this code:
define(['ojs/ojcore', 'knockout', 'ojs/ojtable', 'ojs/ojarraytabledatasource'],
function (oj, ko)
{
function CustomerViewModel() {
var self = this;
self.data = ko.observableArray();
jQuery.getJSON("http://127.0.0.1:7101/MyJETApp/rest/1.0/customer").
then(function (res) {
$.each(res.items, function () {
self.data.push({
Id: this.Id,
Name: this.Name,
Email: this.Email
});
});
});
self.dataSource = new oj.ArrayTableDataSource(
self.data,
{idAttribute: 'Id'}
);
}
return CustomerViewModel;
});
To show a Table in a page: Navigate to Site Root/views - create/edit customers.html file and paste this code:
<div class="oj-hybrid-padding">
<h1>Customers Content Area</h1>
<div>
<table data-bind="ojComponent: {component: 'ojTable',
data: dataSource,a
columns: [
{headerText: 'Id', field: 'Id'},
{headerText: 'Name', field: 'Name'},
{headerText: 'Email', field: 'Email'}
]
}">
</table>
</div>
</div>
Finally copy content on Web folder to public html folder on Fusion Application and run it, more details here: https://mydevelopertools.blogspot.cl/2017/11/run-oracle-jet-application-in-weblogic.html
Rest Application: https://github.com/jtiagomp/JET_POCs/tree/master/FusionRestApp
JET Application: https://github.com/jtiagomp/JET_POCs/tree/master/oraJETRestService
Cheers!
No responses yet for "Create RestService and consume in a JET Application"
Post a Comment