LogoLogo
Download Free TrialLive DemoGet a QuoteContact Us
Thinfinity® VirtualUI 3.0
Thinfinity® VirtualUI 3.0
  • Thinfinity VirtualUI 3.0
  • Architecture
  • Getting Started Section
    • Getting Started
      • Installing Thinfinity VirtualUI
      • Simple UI Remoting
        • Compiling and Testing a WinForms Application
        • Compiling and Testing a Delphi Application
        • Compiling and Testing a C++ Application
        • Registering the Application in Thinfinity VirtualUI Server
        • Accessing the App from the Web
        • Application Execution Behavior
        • List of available demos for download
      • Adapting the Application
        • Customizing the Web Page
          • Preparing the Web Page
          • Customizing Settings
        • Programming VirtualUI
          • Handling VirtualUI Events
          • Using ClientSettings from Javascript
  • Advanced Programming Section
    • Advanced Programming
      • Javascript Remote Objects
        • The Development Lab
        • Life cycle of the jsRO Objects
        • Creating jsRO Objects
        • Updating Properties
        • OnPropertyChange(), OnSet() y OnGet() Events
        • jsRO Remote Calls
          • Remote Methods
          • Custom Events
        • Available demos for Javascript Remote Objects
      • Adding Web Content
        • The HTMLDoc Object
          • Loading Scripts
          • Importing HTML files
          • Accessing local files
          • Creating Web Component instances
        • Web Components
          • Loading Web Component Scripts
          • Importing Web Component HTML files
          • Accessing local resources from the Web Component
  • Advanced Features Section
    • Advanced Features
      • Scaling and Load Balancing
        • Scaling and Load Balancing Configurations
        • Installing components
        • Enabling Multiple RDS Accounts
        • Configuring Load Balancing
        • Sharing your License
          • Installing the License Server Manager
          • Add a Licence
            • Get a new Trial Serial Number
            • Activate a Serial Number Online
            • Activate a Serial Number Offline
          • Sharing your License over multiple Severs
      • Enhanced Browser and DPI Support
        • Model Inheritance
        • Property Reference
        • The Calculation Process
        • Examples
      • One-Time URL
        • How it Works
        • Creating a One-Time URL
      • Passing Command Line Arguments to VirtualUI Apps
        • Setting Command Line Arguments in the Application Profile
        • Sending Command Line Arguments in the VirtualUI URL
        • Building the URL in Javascript
        • Combining Application Profile and URL Command Line Arguments
      • Recording and Playing Sessions
        • Recording a Session
          • The OnRecorderChanged Event
      • Recover Browser Information with BrowserInfo
      • Change Browser Behavior Using ClientSettings
      • End-User Authentication
        • Entering Credentials
        • Processing End-user Credentials
        • Authentication Methods
          • Windows Logon
          • RADIUS
          • OAuth 2.0
            • OAuth2Models.ini
            • CSS for SSO Options
          • External DLL
            • Authentication API
      • Virtualization
        • File System Virtualization
          • Creating File System Redirections
          • The .vdir Files
          • Testing the File System Virtualization
        • Registry Virtualization
          • Creating Registry Redirections
          • The .vreg Files
          • Testing Registry Virtualization
        • Implementing Virtualization in Your Application
      • OEM Licensing
        • How to Create and Revoke Licenses
          • Creating Licenses
          • Revoking Licenses
      • Silent Install Options
  • Web Interface Section
    • Web Interface
      • login.html
      • index.html
      • app.html
        • app.js
        • The DockMenu Widget
        • Printing
          • How to install and use the Printer Agent
          • Printing Preview and Printing
          • Remote Printing SDK for Thinfinity - C#
          • Remote Printing SDK for Thinfinity - Delphi
      • lab.html
  • Configuration Reference Section
    • Configuration Reference
    • Development Server
      • General
      • License Manager
        • Activate a Serial Number Offline
        • Activate a Serial Number Online
        • Get a new Trial Serial Number
        • Proxy Activation
    • Server Manager
      • General
        • Managing the SSL Certificate
          • The Default Embedded Certificate
          • A Self-Signed Certificate
          • A CA Certificate
      • Sessions
      • Applications
        • Application Profile
          • General
          • Credentials
          • Permissions
          • Restrictions
          • Access Hours
          • Authentication Methods
        • Weblink Profile
          • Permissions
      • Authentication
        • Mappings
        • 2FA
          • TOTP
          • Duo Authentication Method Settings
            • How to configure DUO
        • Radius Authentication Method Settings
        • Oauth 2.0 Authentication Method Settings
          • Configure OAuth with Auth0
          • Configure OAuth with Okta
        • External DLL Authentication Method Settings
        • SAML Authentication Method Settings
          • Configure SAML with Okta
          • Configure SAML with Centrify
      • Services
      • License Manager
        • License Activation
          • Proxy Activation
          • Get a new Trial Serial Number
          • Activate a Serial Number Online
          • Activate a Serial Number Offline
    • Gateway Manager
      • Protection
  • Appendix A - Dialogs
    • Appendix A - Dialogs
    • Message Dialogs
      • Message Dlg
      • Input Box
      • Formatted Message
    • Printing Dialogs
      • Print
      • Page Setup
      • Print Preview
    • File Dialogs
      • Open File
      • Save As
  • Appendix B - Tailoring the Interface
    • Customizing the Web Interface
      • Changing the Logo
      • Customizing the Web Files
      • Files Location
  • Symbol Reference Section
    • Thinfinity.VirtualUI Class
Powered by GitBook
On this page
Export as PDF
  1. Advanced Programming Section
  2. Advanced Programming
  3. Javascript Remote Objects

OnPropertyChange(), OnSet() y OnGet() Events

PreviousUpdating PropertiesNextjsRO Remote Calls

Last updated 4 years ago

When publishing a model, jsRO will keep the state of the created object synchronized in the application side and in the browser. Each time a property is updated in the server side, this change is propagated to the browser, where besides updating the value it can be handled by the corresponding .on(“model:object.property”, “change”, …) event, if this event was declared.

When a property is updated on the browser side, this change is sent in the opposite direction (from the web to the application) and triggers an OnPropertyChange event in the instantiated JSObject object. This is a good place to do things like propagating the change of a property value to some other element of the application, update a group of values in a database, etc.

jsRO can also handle changes in the properties of its object through the declaration of the OnSet and OnGet property events.

By invoking the ApplyChanges method on a JSObject object, the collection of the properties added to the object is traversed and if any of these properties has an OnGet event declared, it's triggered.

The OnSet event, however, is executed when it receives a change from a particular property from the browser.

The way to add the OnSet and OnGet event handlers to a property is based on their definition, you can do so when of adding the property or afterwards, always remember to fire an ApplyModel so that the model is propagated to the browser.

The next example shows how the browser can retrieve the application form background color in a #RRGGBB format, and also how to change the background color using a value sent from the browser. Since the desktop application doesn't interpret colors like the web does, we need a conversion that works both ways:

Delphi Definition:

// Creates the remote object
 FRo := TJSObject.Create('ro');
 // Property definition
 FRo.Properties.Add('backgroundColor')
 .OnGet(TJSBinding.Create(
 procedure(const Parent: IJSObject; const Prop: IJSproperty)
 begin
 Prop.AsString := '#'
 + IntToHex(GetRValue(ColorToRGB(Form1.Color)), 2)
 + IntToHex(GetGValue(ColorToRGB(Form1.Color)), 2)
 + IntToHex(GetBValue(ColorToRGB(Form1.Color)), 2);
 end))
 .OnSet(TJSBinding.Create(
 procedure(const Parent: IJSObject; const Prop: IJSproperty)
 var
 value: string;
 begin
 value := LowerCase(Prop.AsString);
 if ((Length(value) = 7) and (copy(value, 1, 1) = '#')) then
 begin
 try
 Form1.Color := RGB(
 StrToInt('$' + Copy(value, 2, 2)),
 StrToInt('$' + Copy(value, 4, 2)),
 StrToInt('$' + Copy(value, 6, 2))
 );
 except
 end;
 end;
 end));

.Net definition:

// Creates the remote object
 ro = new JSObject("ro");
 // Property definition
 ro.Properties.Add("backgroundColor")
 .OnGet(new JSBinding(
 // This anonymous procedure do the actual get
 delegate(IJSObject Parent, IJSProperty Prop)
 {
 Prop.AsString = "#"
 + this.BackColor.R.ToString("X2")
 + this.BackColor.G.ToString("X2")
 + this.BackColor.B.ToString("X2");
 }))
 .OnSet(new JSBinding(
 // This anonymous procedure do the actual set
 delegate(IJSObject Parent, IJSProperty Prop)
 {
 string value = Prop.AsString.ToLower();
 Regex reColor = new Regex(@"^#([0-9,a-f]{6})$");
 Match match = reColor.Match(value);
 if (match.Success)
 {
 string color = match.Groups[1].Value;
 this.BackColor = Color.FromArgb(
 int.Parse(color.Substring(0, 2), NumberStyles.AllowHexSpecifier),
 int.Parse(color.Substring(2, 2), NumberStyles.AllowHexSpecifier),
 int.Parse(color.Substring(4, 2), NumberStyles.AllowHexSpecifier)
 );
 }
 }));

Assigning the property value in Javascript:

ro.backgroundColor = “#FF0000”;