0

I have created a Sample application in Oracle JET using Oracle JET QuickStart Basic template. I want the application to have communication between two mudules. I have tried using the steps mentioned in Geertjan's blog Intermodular communication in Oracle JET(Part 2) and Intermodular communication in Oracle JET(Part 3) but unfortunately it doesn't seem to work. It would be a great help if someone explain me how to do Intermodular communication using Oracle JET QuickStart Basic template. Thank you.

Arun
  • 15
  • 1
  • 7
  • Can you provide any more details about what you have tried and what errors you are getting? As you can tell from the blog posts you've read, there are multiple ways to do this. – peppertech May 21 '17 at 19:40

2 Answers2

2

While navigating to other module you can pass some parameters.

<!-- Module binding with params -->
<div data-bind="ojModule: {name: currentName, params: currentName}"></div>

http://www.oracle.com/webfolder/technetwork/jet/jsdocs/ojModule.html

and variables can be initialized with parameters while module is attached

self.handleAttached = function (info) {
          var param = ko.utils.unwrapObservable(info.valueAccessor()).params;
          console.log(param);
          self.variableToBeInitialized= param;
          };

https://docs.oracle.com/middleware/jet230/jet/reference-jet/oj.ModuleBinding.ConventionMethods.html

Andagar
  • 61
  • 11
1

You can use global variable which can be accessed/modified from all modules.

Step 1: Define variables(in appController.js/main.js) to be communicated across the modules.

self.var1= ko.observable("");
self.var2= ko.observable('');

Step 2: In modules you can access the variables after getting rootModel-

self.rootModel = ko.dataFor(document.getElementById('globalBody'));

var variable1= self.rootModel.var1;
var variable2= self.rootModel.var2;

Hope this helps!

Thanks

Ankit Kumar
  • 393
  • 2
  • 3
  • 18