Java Magazine, March/April 2017
ORACLE COM JAVAMAGAZINE MARCH APRIL 2017 45 ui tools using a Promise to allow the chart to render only once the data is available self seriesValue new Promise function resolve reject var url https api data gov nrel alt fuel stations v1 nearest json location self cityVal self selectVal api_ key your api key goes here getJSON url then function data var fuels data station_ counts fuels var seriesData for var prop in fuels if fuels prop total 0 seriesData push name getFuelName prop items fuels prop total resolve seriesData This code uses a JavaScript Promise to return the results of the call to the REST service after the data is actually ready The Promise object is a new addition in the ECMAScript 2015 language specification also known as ES6 that helps when you are working with asynchronous data such as REST calls Because Oracle JET is a pure client side toolkit the only way to consume and interact with remote data is via web services such as REST or WebSocket You can use any method you like for making the web service call The most common way is to use jQuery Ajax methods or jQuery getJSON but you can use plain JavaScript XMLHttpRequest API calls as well For more complex data interactions such as those used in applications that need to create read update and delete CRUD data Oracle JET provides a Common Model API that simplifies working with multiple types of data sources You can read more about the Common Model API in the Framework section of the Oracle JET Cookbook Oracle has used Oracle JET as the foundation for more than 70 percent of its new cloud service offerings If you would like to take a closer look at the sample application and run it in your own development environment you can clone the project from GitHub Installation and configuration steps are included in the README file for the project Conclusion While Oracle JET has actually been around for more than three years it has been available to the open source community for only about one year Oracle has used Oracle JET as the foundation for more than 70 percent of its new cloud service offerings so you know that it meets the needs of very large enterprise scale applications Oracle JET is most powerful when you understand the concepts and ideas behind its creation To get that understanding you can read the developers guide or take the free online training course login required Both are great resources for beginners and developers For announcements and interaction with others using Oracle JET follow @ oraclejet on Twitter or engage with other developers on the Oracle JET Community site article John JB Brock has spoken at JavaOne Oracle OpenWorld and many Developer Days events over the last decade He is a coauthor of Java EE and HTML5 Enterprise Application Development McGraw Hill 2014 a two time winner of the JavaOne Rock Star Award and the senior product manager for Oracle JET
You must have JavaScript enabled to view digital editions.