5526. x0-Object Modeling
66======================
77
8- The following sections explain how to design custom x0 system objects and define
9- their specifications for seamless integration into the core system.
8+ The following sections explain how to design ** custom ** * x0- system- objects* and
9+ define their ** specifications ** for seamless integration into the core system.
1010
111126.1. Basic Modeling Rules
1212--------------------------
1313
14- You should have a solid understanding of the following x0 fundamentals before
14+ You should have a ** solid understanding ** of the following * x0 * fundamentals before
1515continuing:
1616
1717- Base Classes / Inheritance
18- - Child Objects
18+ - Child Objects / Parent Object
1919- Event Handler / Callbacks
2020- Building Object Structure (DOM)
2121- Modifying Runtime Data
22- - Object Realtime Updating
22+ - Object Realtime Updates
23+ - Object Initialization
24+ - Adding Context Menu Functionality
2325
242626.1.1. Base Classes / Inheritance
2527**********************************
2628
2729You should familiarize yourself with the x0 *Core Base Model *.
2830Refer to: :ref: `devoopmodel_base `.
2931
30- 26.1.2. Child Objects
31- *********************
32+ Any **custom ** *x0-system-object * must inherit ``sysBaseObject `` in its prototype.
33+
34+ .. code-block :: javascript
35+
36+ // - inherit sysBaseObject
37+ sysObjNewcomer .prototype = new sysBaseObject ();
38+
39+ 26.1.2. Child Objects / Parent Object
40+ *************************************
41+
42+ The ``self.ChildObjects[] `` model in ``sysBaseObject.js `` is an array that
43+ manages the child objects of a ``sysBaseObject `` instance. It functions as a
44+ recursive container for hierarchical object structures within the
45+ *x0-framework *.
46+
47+ 1. Initialization
48+
49+ In any new modeled Object's constructor, ``this.ChildObjects[] `` must be initialized
50+ as an empty array:
51+
52+ .. code-block :: javascript
53+
54+ this .ChildObjects = new Array (); // - Child Objects
55+
56+ 2. Child Object Relationships
57+
58+ Each child object in the array is an instance of ``sysBaseObject `` or its derived classes.
59+ A parent-child relationship is established using the ``ParentObject `` property.
60+
61+ This enables any child object to directly access its parent(s).
62+
63+ .. code-block :: javascript
64+
65+ // - Do something in the ParentObject
66+ this .ParentObject .doSomething ();
67+
68+ // - Do something in the ParentObject.ParentObject
69+ this .ParentObject .ParentObject .doSomething ();
70+
71+ 3. Add Objects
72+
73+ Adding objects to self is done like this:
74+
75+ .. code-block :: javascript
76+
77+ // - add new sysObjDiv()
78+ let Obj1 = new sysObjDiv ();
79+ Obj1 .ObjectID = ' MyDiv1' ;
80+
81+ // - add Obj1 to parent
82+ this .addObject (Obj1);
83+
84+ see: :ref: sysBaseObject.addObject()
85+
86+ 4. Propagate Object(s) to DOM
87+
88+ .. code-block :: javascript
89+
90+ // - render all ParentObject.ChildObjects[]
91+ this .ParentObject .renderObject ();
3292
3393 26.1.3. Event Handler / Callbacks
3494*********************************
3595
96+ If you want to process native DOM Events (not *x0-events *),
97+ in any new modeled Object's constructor, ``this.EventListeners[] `` must be
98+ initialized as an empty array:
99+
100+ .. code-block :: javascript
101+
102+ this .EventListeners = new Array (); // - Array of EventListener Objects
103+
104+ 1. Add Event Listeners
105+
106+ .. code-block :: javascript
107+
108+ let EventListenerObj = new Object ();
109+ EventListenerObj[' Type' ] = ' mousedown' ; // - Event Type 'mousedown'
110+ EventListenerObj[' Element' ] = this .EventListenerCallback .bind (this ); // - Callback Method
111+ this .EventListeners [' ListenerID' ] = EventListenerObj; // - Add Listener with ListenerID
112+
113+ 2. Multiple Event Listeners
114+
115+ When adding multiple Event Listeners, processing order will be preserved.
116+
117+ 3. Event Listener Activation
118+
119+ After adding Event Listeners in Realtime Objects, they have to be explicitely
120+ activated before working.
121+
122+ .. code-block :: javascript
123+
124+ this .processEventListener ();
125+
126+ 4. sysButtonCallback Object
127+
128+ The ``sysButtonCallback `` *x0-object * can be used to asbtract ...
129+
3613026.1.4. Building DOM Object Structure
37131*************************************
38132
133+ See :ref: `devporting `.
134+
3913526.1.5. Modifying Runtime Data
40136******************************
41137
@@ -44,34 +140,59 @@ Refer to: :ref:`devoopmodel_base`.
44140- RuntimeAppend(Data)
45141- XML-RPC Async Data
46142
47- 26.1.6. Modifying Runtime Data
48- ******************************
143+ 26.1.6. Updating Realtime Objects
144+ *********************************
145+
146+ 1. remove()
147+ 2. removeParent()
148+ 3. RTfunctions
149+ 4. Examples
150+
151+ 26.1.7. Object Loading / Initialization
152+ ***************************************
153+
154+ 1. init()
155+
156+ 26.1.8.Adding Context Menu Functionality
157+ ****************************************
158+
159+ 1. Add Event Listener init()
160+ 2. Setup Context Menu
161+ 3. Eventually extend
49162
50- - Different approaches remove() and removeParent() + RTfunctions
51163
5216426.2. Building an Object Like sysObjDynRadioList.js
53165---------------------------------------------------
54166
55167This section explains how to create a dynamic system object similar to
56- `sysObjDynRadioList.js ` in the x0 framework. It focuses on the structure,
57- methods, and key principles used in `sysObjDynRadioList `.
168+ ``sysObjDynRadioList.js `` in the *x0-framework *. It focuses on the structure,
169+ methods, and key principles used in ``sysObjDynRadioList ``.
170+
171+ 26.2.1. Overview
172+ ****************
58173
59- - Overview
174+ The ``sysObjDynRadioList `` is a **dynamic object ** designed to manage a list of
175+ **radio buttons **, with rows that can be added or removed at runtime. Each row
176+ includes a **radio button **, an **input field **, and **associated controls **.
60177
61- The sysObjDynRadioList is a dynamic object designed to manage a list of radio
62- buttons, with rows that can be added or removed at runtime. Each row includes a
63- radio button, an input field, and associated controls.
178+ 26.2.2. Key Components
179+ **********************
64180
65- - Key Components:
181+ 1. Base Object Inheritance:
182+ Inherits from ``sysBaseObject `` for core functionality.
183+ 2. Dynamic Rows:
184+ Rows are represented by ``sysObjDynRadioListRow ``, which also inherits from ``sysBaseObject ``.
185+ 3. Callbacks and Events:
186+ Used for adding/removing rows and handling user interactions.
187+ 4. JSON Configuration:
188+ Utilized for defining object attributes and styles.
66189
67- 1. Base Object Inheritance: Inherits from sysBaseObject for core functionality.
68- 2. Dynamic Rows: Rows are represented by sysObjDynRadioListRow, which also inherits from sysBaseObject.
69- 3. Callbacks and Events: Used for adding/removing rows and handling user interactions.
70- 4. JSON Configuration: Utilized for defining object attributes and styles.
190+ 26.2.3. Step-by-Step Guide
191+ **************************
71192
72- - Step-by-Step Guide
193+ Following, a Step-by-Step Guide, guiding you through the creation process.
73194
74- 26.2.1 . Create the Base Class
195+ 26.2.2 . Create the Base Class
75196*****************************
76197
77198Start by defining your main object, inheriting from sysBaseObject:
@@ -88,7 +209,7 @@ Start by defining your main object, inheriting from sysBaseObject:
88209 // Inherit from sysBaseObject
89210 sysObjDynRadioList .prototype = new sysBaseObject ();
90211
91- 26.2.2 . Initialize the Object
212+ 26.2.3 . Initialize the Object
92213*****************************
93214
94215Define the init method to set up the object structure and default components:
@@ -120,10 +241,11 @@ Define the init method to set up the object structure and default components:
120241 );
121242 };
122243
123- 26.2.3 . Define the Row Class
244+ 26.2.4 . Define the Row Class
124245****************************
125246
126- Each row in the list is represented by sysObjDynRadioListRow. This class manages its elements (radio button, input field, and optional remove button):
247+ Each row in the list is represented by ``sysObjDynRadioListRow ``. This class manages its
248+ elements (radio button, input field, and optional remove button):
127249
128250.. code-block :: javascript
129251
@@ -169,10 +291,10 @@ Each row in the list is represented by sysObjDynRadioListRow. This class manages
169291 }
170292 };
171293
172- 26.2.4 . Add Rows Dynamically
294+ 26.2.5 . Add Rows Dynamically
173295****************************
174296
175- The add method in sysObjDynRadioList creates new rows dynamically:
297+ The add method in `` sysObjDynRadioList `` creates new rows dynamically:
176298
177299.. code-block :: javascript
178300
@@ -201,7 +323,7 @@ The add method in sysObjDynRadioList creates new rows dynamically:
201323 this .renderObject (this .DOMParentID );
202324 };
203325
204- 26.2.5 . Handle Row Removal
326+ 26.2.6 . Handle Row Removal
205327**************************
206328
207329The remove method in sysObjDynRadioListRow is used to remove a row:
@@ -220,10 +342,10 @@ In the parent object, the remove method manages the array of rows:
220342 this .RowItems [RowIndex].remove ();
221343 };
222344
223- 26.2.6 . Define Object Structure
345+ 26.2.7 . Define Object Structure
224346*******************************
225347
226- Use the addObjects method to define the DOM structure for each row:
348+ Use the `` addObjects `` method to define the DOM structure for each row:
227349
228350.. code-block :: javascript
229351
@@ -269,7 +391,7 @@ Use the addObjects method to define the DOM structure for each row:
269391 sysFactory .setupObjectRefsRecursive (ObjDefs, this );
270392 };
271393
272- 26.2.7 . Conclusion
394+ 26.2.8 . Conclusion
273395******************
274396
275397By following this guide, you can create dynamic objects similar to sysObjDynRadioList.js.
0 commit comments