OCLOperators RootObject
No edit summary
(Replacing message template with parser tag)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<message>Write the content here to display this box</message>
selfVM.RootObject gives access to the object rooting a ViewModel instance. This is read-only and you can use it like this:
selfVM.RootObject gives access to the object rooting a ViewModel instance. This is read-only and you can use it like this:


<code>selfVM.RootObject->safeCast(Thing).SomeString:='a new value'</code>
<code>selfVM.RootObject->safeCast(Thing).SomeString:='a new value'</code>


Why is the selfVM.RootObject not typed but requires a cast to be used with the real root? Because OCL is a statically typed language and selfVM is context sensitive, meaning it is available in all ViewModels - there is no 1 answer to what type the RootObject should have. If you are in the context of a ViewModel, you will however know what type it has and can safely cast.
Why is the selfVM.RootObject not typed but requires a cast to be used with the real root? Because OCL is a statically typed language and selfVM is context sensitive - meaning it is available in all ViewModels - there is no one answer to what type the RootObject should have. If you are in the context of a ViewModel, you will however know what type it has and can safely cast.
[[Category:OCLOperators]]
[[Category:OCLOperators]]
{{Edited|July|12|2024}}

Latest revision as of 07:49, 17 June 2024

selfVM.RootObject gives access to the object rooting a ViewModel instance. This is read-only and you can use it like this:

selfVM.RootObject->safeCast(Thing).SomeString:='a new value'

Why is the selfVM.RootObject not typed but requires a cast to be used with the real root? Because OCL is a statically typed language and selfVM is context sensitive - meaning it is available in all ViewModels - there is no one answer to what type the RootObject should have. If you are in the context of a ViewModel, you will however know what type it has and can safely cast.

This page was edited 95 days ago on 06/17/2024. What links here