lastModified and lastModifiedBy fields in AEM nodes - properties

Does anyone know why sometimes the node would have 2 additional fields - jcr:lastModified and jcr:lastModifiedBy
while some nodes don't have these 2 fields?

In JCR the jcr:lastModified and jcr:lastModifiedBy properties are automatically set by the repository when certain changes are made to a node. These properties are used to track when a node was last modified and who made the modification.
The jcr:lastModified property is a date-time value that is set to the current date and time whenever the node's content or properties are modified, or whenever a child node is added or removed from the node. The jcr:lastModifiedBy property is a string value that is set to the username of the user who made the modification.
Not all nodes will have the jcr:lastModified and jcr:lastModifiedBy properties, as these properties are only set when certain changes are made to the node. For example, if a node is created but its content and properties are not modified, the jcr:lastModified and jcr:lastModifiedBy properties will not be set. It is also possible to disable the automatic setting of these properties by modifying the repository's configuration. If the automatic setting of these properties has been disabled, then no nodes in the repository will have the jcr:lastModified and jcr:lastModifiedBy properties.

Related

VUE 3 JS Save value if object changes

I'm new to VUE but not to programming. The project is to convert an older server-built website to VUE and I'm looking to find the most efficient method to save data.
When a form (page) is loaded I pull the data from our server in a JSON object which is nicely converted to a JS object. Its big -- hundred or so properties.
I'm currently storing the object in a PINIA store as a reactive object, applying the object values directly to form inputs using v-model and everything works, is reactive, and once completed my object has all the necessary information to update (patch) the document.
What I'd like to do is send to the server JUSt the object that was changed and its new value.
For example: assume the object has many fields -- I'll just provide a few here
event:{user:'scott',pass:'12345',startDate:'11/01/2023',endDate:'11/01/2024'.....}
The page has tabs and in each tab we pull a subset of the complete object (fetched and stored).
Therefore, store.event object has one change -- startDate --
I'd like to build a function that watches the entire (100+ object), fire if any field has changed, then save it somewhere without an individual watch or computed property for each 100+ objects.
Suggestions?
I tried using watch with multiple elements -- it did fire but I was unable to determine which element (object) changed.
Watch(() => [store.event.contractdate,store.event.contractduedate],(cv,ov){.. do something}

vue.js reactivity how dependency class might have many watcher subscribers

As you know, for each data property, there's a new Dep class created. Each Dep class has subscribers of watchers.
I looked through vue.js source code and for each component, there's only ONE watcher class being created which also holds the render function(template of the component).
1) Could you describe the situation when and why data property of one of the components might have the Dep class which has more than one watcher class?
2) So can I sum up something like this: if we have a component which has 5 data properties. each of these 5 data properties has different Dep class instance. and each of those Dep class has the same Watcher and that watcher holds the component's render function. If state changes, one of those 5 Dep class's notify gets run and that notify runs its watcher's render function?
You may find this introduction useful:
https://medium.com/dailyjs/tracing-or-debugging-vue-js-reactivity-the-computed-tree-9da0ba1df5f9
As you've mentioned, each data property will have its own instance of Dep. Each Dep has a subs property that holds an array of subscribers. The subscribers in that array will all be instances of the Watcher class. If a data property changes then the corresponding Dep will notify each Watcher in its subs.
Each Watcher also holds references back to its dependencies, in a property called deps. This is just an array of the Dep objects to which the Watcher is subscribed.
You'll be able to see this in your browser developer tools. If you log a Vue instance you'll find a property called _watchers that holds all the watchers related to that component. Expanding their deps will lead you to the Dep objects, though it can be tricky to tell exactly which data property each Dep represents.
The rendering process has a Watcher that it uses to track its data dependencies. You'll only get one of those per component instance.
A Watcher is also created if you use watch or $watch. Again you'll be able to see these in _watchers.
Computed properties have one Watcher each. Those will be present in the _watchers array but it's easier to see them in _computedWatchers.
A key thing to note is that dependencies are flattened. If you use a computed property you'll actually just get a dependency on all the data properties that contributed to it. You can't form a direct dependency on the computed property itself.
So to go back to your original question:
Rendering, computed properties and watch will all contribute to the subs of a Dep. Computed properties will often contribute more subscribers than you might expect due to the flattening of the dependencies.
Almost. The render function isn't called directly. When the Watcher for rendering is notified of a data change it will actually just add the component to a queue. That rendering queue won't be processed until the start of the next tick.

Changing a oneway bound TextBlock value from code behind.

I have a TextBlock and its Text property is bound to a ViewModel property. The binding is Oneway.
When I change the Text property of the Control from the xaml.cs the binding gets broken. If the binding is TwoWay I don't have this problem but the source property is updated too. Is it possible to have OneWay binding and change the target property value without braking the binding?
I suggest a workaround, like setting the Binding to TwoWay and ignore the update in the property. Something like this:
private string textValue;
public string TextValue
{
get { return textValue; }
set
{
:
}
}
Now the Property can no longer be set by the view.
Although no code is provided, this scenario typically occurs when you have bound a control to a view model and at a later stage your logic tries to update the value in the control programmatically.
You should not try to do this, that is define multiple sources of the value for a control. If you bind the control to a property on the view model, then to update the value in the control you should update the field in the view model.
If you were to set the value of a bound control programmatically at runtime so that it no longer matched the bound object value, when some other event causes the control binding to be re-evaluated, the value that you have provided programmatically would be overwritten again, you could easily end up with a scenario where the value you provided programmatically is never visible to the user.
In this scenario you should either:
Add a new property to the view model, bind this value to the control, then your program logic can set this value equal to the original property when the data is loaded, and updated when you need to
Not use bindings at all, always write to the control programatically that way you tightly control when the value is updated.
There is a workaround to this if you absolutely must have one. if you are using compiled bindings (x:Bind), then because the bindings are compiled it is possible to call SetValue on the bound dependency property at runtime and the previously compiled bindings will still be evaluated. However I advise against exploiting this because it makes your code a lot harder to follow and debug, when bindings are used, we tend not to look for code that directly addresses and sets control values.

How to restore an object in Silverlight 5

I have created an application by using Silverlight 5. There are many two-way databind in it. I want to retore a change in UI by restoring the object behind. For example:
I have an object behind which contains properties double Left, Right, I inherited it from INotifyPropertyChanged. In UI, I created tow button (ButtonLeft and ButtonRight) and their parent a Canvas Control, ButtonLeft bind Left property in two-way mode and ButtonRight bind Right property in two-way mode. It works very well, if I drag ButtonLeft, then the Left property will be updated with the new Left Value, same for ButtonRight.
Is there any way to restore the old value after the change of UI. Actually, the relation of class in my application is very complicated, I have already knew that retore the value of property in object will restore the UI, so is there any way (more general and loose-coupling) to restore all the objects that need to be restored.
I have thought of creating an interface IRestorable (inside Store(), Restore()) for objects that need to save and restore state. An attribute Restorable for property which need to be restored. For me, the use of AOP could be a good idea, each time when an instance of IRestorable is created, AOP will call a method for saving the current state (properties which is marked an [Restorable]) of object. I don't know if I was on the right way. If not, any advice will be appreciated.
Use of memeno design pattern.
http://www.codeproject.com/Articles/18025/Generic-Memento-Pattern-for-Undo-Redo-in-C

Can a node in dynatree have several parents?

Using this http://wwwendt.de/tech/dynatree/
I know the answer is probably no, but I want to verify this: can a node have several parents in this component?
That would mean, that nodes with identical properties (title, icon, and other attributes) appear at different locations in the tree.
This is possible, of course.
The only restriction is: It's not allowed to have two nodes with the same key property in one tree.
I think that the behaviour would be hard to define, if nodes where really 'identical'. For example, when you activate one node that has multiple parents, would you expect all instances to be highlighted? And then, when you press [Cursor-Left]: which parent should be navigated to?
But you could add a new property like myBackendKey whith the same value for all node instances.
Yes, a node in DynaTree can have multiple parents. That is: one identical node can be assigned to more than one parent node in the same tree. I am using jQuery Dynatree Plugin v1.2.2.
I've just now encountered a situation where I've had to deal with duplicate nodes in conjunction with navigating from current node to its next/prev sibling.
Since I had dublicate nodes in the tree, the navigation was broken. When querying the tree for a node with key "abc", dynatree will give you only the first occourance of the node with that key (and not care about the remaining nodes with the same key).
Solution: To prevent this from happening, I've simply prefixed the key for duplicate nodes with a unique string.