Managing Persisted State for Oracle JET Web Component Variable With Writeback Property – DZone Database | xxxManaging Persisted State for Oracle JET Web Component Variable With Writeback Property – DZone Database – xxx
菜单

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property – DZone Database

十月 26, 2018 - MorningStar

Over a million developers have joined DZone.
Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

{{announcement.body}}

{{announcement.title}}

Let’s be friends:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property

DZone’s Guide to

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property

We take a look at the updated Web Component in Oracle’s JET and its writeback property, why it’s important, and how to use it.

Nov. 13, 18 · Database Zone ·

Free Resource

Join the DZone community and get the full member experience.

Join For Free

Compliant Database DevOps and the role of DevSecOps DevOps is becoming the new normal in application development, and DevSecOps is now entering the picture. By balancing the desire to release code faster with the need for the same code to be secure, it addresses increasing demands for data privacy. But what about the database? How can databases be included in both DevOps and DevSecOps? What additional measures should be considered to achieve truly compliant database DevOps? This whitepaper provides a valuable insight. Get the whitepaper

Starting from JET 6.0.0, Composite Components (CCA) are renamed to be Web Components (I like this new name more, it sounds more simple to me). In today’s post, I will talk about Web Component writeback property and importance of it.

All variables (observable or not) defined inside Web Component will be reset when navigating away and navigating back to the module where Web Component is included. This means you can’t store any values inside Web Component, because these values will be lost during navigation. Each time when we navigate back to module, all Web Components used inside that model will be reloaded, this means JS script for Web Component will be reloaded and variables will be re-executed loosing previous values. This behaviour is specific to Web Component only, values for variables created in the owning module will not be reset.

If you want to keep Web Component variable value, you will need to store variable state outside of Web Component. This can be achieved using Web Component property with writeback support.

Let’s see how Web Component behaves on runtime. Source code is available on my GitHub repo.

Here I got basic Web Component included into dashboard module:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Web Component doesn’t implement anything except JET switcher. Once switcher state is changed, variable is updated in JS script:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Variable that holds switcher state in Web Component:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Web Component is reloaded each time we navigate away and come back to the module — this means variables will be reset. This is what it looks like — imagine we open module for the first time, switcher position is OFF:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Change it to be ON:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Navigate to any other module and come back — you will see that switcher is reset back to default OFF state, this means variable was reset (otherwise we should see ON state):

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

If you want to keep variable state, then it should be maintained outside of Web Component. To achieve this, create Web Component property to hold variable value, make sure set this property with writeback support:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

For debugging purposes, add logging into Web Component, this will help to see when it will be reloaded:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Switcher variable must be initialized from Web Component property. The very first time it will be empty, but as soon as user will changed switcher state — next time when Web Component is reloaded, it will assign correct value which was selected before:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

When switcher state is changed, we need to handle this event and make sure that Web Component property is updated with new value:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Writeback property must be assigned with observable variable, which is created in the module. Variable reference must be writable with {{}} brackets:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Once value will be changed inside Web Component, this change will be propagated up to observable variable defined in the module. Next time when we navigate away and come back to the module — we will pass recent value to the Web Component:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

This is how it works now. Load module, change switcher state (see in the log — Web Component was loaded once):

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Navigate to any other module:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Come back to the module, where Web Component is included. See in the log — Web Component is reloaded, but switcher variable value is not lost, because it was saved to module observable variable through Web Component writeback property:

Managing Persisted State for Oracle JET Web Component Variable With Writeback Property - DZone Database

Compliant Database DevOps and the role of DevSecOps DevOps is becoming the new normal in application development, and DevSecOps is now entering the picture. By balancing the desire to release code faster with the need for the same code to be secure, it addresses increasing demands for data privacy. But what about the database? How can databases be included in both DevOps and DevSecOps? What additional measures should be considered to achieve truly compliant database DevOps? This whitepaper provides a valuable insight. Get the whitepaper

Topics:
database ,oracle ,integration ,property ,web components ,web dev ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

Database Partner Resources

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.linkDescription }}

{{ parent.urlSource.name }}

· {{ parent.articleDate | date:’MMM. dd, yyyy’ }} {{ parent.linkDate | date:’MMM. dd, yyyy’ }}


Notice: Undefined variable: canUpdate in /var/www/html/wordpress/wp-content/plugins/wp-autopost-pro/wp-autopost-function.php on line 51