MDriven: AccessGroups in Visible Expression ViewModel's column - mdriven

Can we use an AccessGroup name to make visible a column in a ViewModel?
For instance, if we have an AccessGroup called "IsLoggedIn" can we use it in Ocl to set Visible Expression for a column in a ViewModel?
What it would be the Ocl Expression to access the AccessGroup "IsLoggedIn" variable?
Thanks

Related

Binding a CollectionView item to a member variable, not a property

I am using .net MAUI's <CollectionView> with a nested <CollectionView.ItemTemplate> to bind to a collection of objects. I understand how to define the item template so that it contains Label objects that bind to properties of the objects in the collection: using (for example) Text="{Binding Surname}". This works correctly.
I'd also like to bind to a collection of objects that expose readonly member variables, not properties, but binding by name does not result in a value being displayed. No runtime errors occur.
Is there a way to bind collection view items to member variables?
(Using VS 2022 Preview 7.4.0 with .net 6)
Is there a way to bind collection view items to member variables?
No, it only works with public properties. This is simply the way it's implemented. The XAML binding engine will go through the object that serves as a binding context and will look for public properties only.
A work-around is to add a property that returns the member variable.
Given MyType MyVariable;, add:
public MyType MyProperty => MyVariable;
That is shorthand for public MyType MyProperty { get { return MyVariable; } }.

What does the underscore mean before a variable in Swiftui in an init()?

What does the underscore mean before momentDate? Why is it needed?
The underscored variable name refers to the underlying storage for the Binding struct. This is part of a language feature called Property Wrappers.
Given one variable declaration, #Binding var momentDate: Date, you can access three variables:
self._momentDate is the Binding<Date> struct itself.
self.momentDate, equivalent to self._momentDate.wrappedValue, is a Date. You would use this when rendering the date in the view's body.
self.$momentDate, equivalent to self._momentDate.projectedValue, is also the Binding<Date>. You would pass this down to child views if they need to be able to change the date.
For Binding, the "projected value" ($) is just self, and the difference between _ and $ is only in the access level. However, other property wrappers may project a different type of value (see the #SmallNumber example in the language guide).

Expression Binding for Property in SAPUI5

I'm trying to set the property of a control using another control's property. In my case, I have one <sap.m.Select> and a <sap.m.Input>. The visible of <sap.m.Input> will depend on the selectedItem of the <sap.m.Select>. IMO, there is an available approach using Expression binding in XML View but I don't know how. Any suggestion?
You can use two way binding so that both properties are binding expressions over the same property in the model.
So you can create a JSON model for example and put there a property called selectedItem. The binding of the properties should be: on select selectedItem={mymodel>selectedItem} and on input visible={parts: [{path: "mymodel>selectedItem"}], formatter: function (selectedItem) {<your manipulation>} }.
You can do that with JavaScript and with XML view. In XML view you should reference to a formatter method in the controller.

Class Diagram: How to represent an array of something as an operation parameter?

In an interface method I want to have a collection of SomeType as an input parameter. How do I represent that within a Class Diagram in EA?
I tried using "SomeType[]" as parameter type, but EA doesn't seem to keep track of this: for instance when I rename the class SomeType to something else, the change doesn't propagate here.
You can specify multiplicity for each parameter of your method.
Parameter multiplicity is not directly visible in the class diagram even if you select "Full detail" in Parameter visibility in Diagram properties. But it is in the model.
The answer is unfortunately: you can't. EA does store the name only and not the reference to the class when you specify a parameter. There are other places where that's also the case (I currently can't recall where). So if you need to track that you need to write a smart SQL to list the used parameters.
Such a SQL could look like:
SELECT * FROM t_operationparams where Type = '<Search Term>'

MVVM Group Radio Button

What is the best way of binding a number of RadioButtons to an enum using MVVM?
The only way I can think of is binding each group box's IsChecked to a property, and in the setter of that property assign a value to an enum in the view model.
You could display the Enum values in a ListBox and provide a special ItemTemplate with a RadioButton plus the name of the Enum. The RadioButton's IsChecked property could then be bound to the ListBoxItem's IsSelected property. Of course, you would have to set the ListBox's SelectionMode to Single.