Data Properties hold the state of your component and are defined with a data structure. Each data property is assigned a default value and is automatically synchronized between server and client.
Data properties are reactive - when an action modifies a property, CBWIRE automatically re-renders only the affected parts of your template. They can hold strings, numbers, booleans, dates, arrays, and structures, and are directly accessible in templates without special syntax.
//./wires/SomeComponent.bxclassextends="cbwire.models.Component"{ data ={"propertyName":"defaultValue"};}
JavaScript parses your data properties. Your data properties can only store JavaScript-friendly values: strings, numerics, arrays, structs, or booleans.
Single or double quotes must surround property names.
JavaScript is a case-sensitive language, and CFML isn't. To preserve the casing of your property names, you must surround them with quotes.
Don't do this.
data={propertyName:"defaultValue"};
Data properties are visible to JavaScript. You SHOULD NOT store sensitive data in them. Use locked properties for additional protection against client-side modifications.
Accessing From Actions
Using the data structure, you can access data properties from within your component actions.
Accessing From Templates
You can access data properties within your templates using #propertyName#.
Resetting Properties
You can reset all data properties to their original default value inside your actions using reset().
You can reset individual, some, or all data properties.
You can also reset all properties EXCEPT the properties you pass.
Locked Properties
Locked properties prevent client-side modifications to sensitive data like user IDs, roles, or permissions. Define a locked variable to protect specific properties from wire:model and other client interactions. CBWIRE throws an exception if locked properties are modified from the client.
Single Property
Multiple Properties
Template Usage
Locked properties can be displayed but not modified through form inputs:
Content: Lock author IDs, creation dates, publication status
Locked properties only prevent client-side modifications. Server-side code in your action methods can still modify locked properties when necessary.
Remember that locked properties are still visible in the client-side JavaScript. For truly sensitive data that shouldn't be visible to users, avoid including it in data properties altogether and access it through server-side services instead.