CUBA : inject Container in Editor - cuba-platform

I have a standard ProductEdit screen extending AbstractEditor.
I am trying to #Inject the root Container of the components hierarchy, in order to walk the hierarchy and add a ValueChangeListener that would change the style.
To do so, I injected the scroll box which is the root in this case. No chance (NPE, no injection).
Then I tried upwards by calling getParent() on one of the component I injected, no parent, NPE.
How can I walk the component hierarchy with CUBA ?

Related

TornadoFX (JavaFX):How to perform action when view becomes visible

I'm new to TornadoFX and I'm having trouble detecting if a view is visible or not
My scenario is:
I have views with custom menu items, I have already added the framework to ensure these are all added to my main menubar.
What I want to do now is make these visible/invisible if the given view is visible to the user.
My views are (in this instance) part of tabs in a tab pane. similar to...
root = tabpane {
tab {
content = MyView.root
...
I have tried
root.focusedProperty().onChange { state -> menu.isVisible = state }
This works when I click on the view (a list view in this case) but this view is not automatically focussed when I select the tab.
I have also tried
root.visibleProperty().onChange { state -> menu.isVisible = state }
but this property does not change when the view is "Shown" by selecting the tab (I assume this property is only set if I manually show/hide the view)
I could move the logic up to the tab itself but this breaks encapsulation.
The view should not have to know that it's part of a tab and the tab should not have to know that part of its content tree require triggering
Is there a property I can use (or another mechanism) to detect if the user can see the view
i.e. if the view is upper most within the application?
As a separate question, is this the right approach or is there a built in way of achieving the dynamic menus? - This is something I took for granted in .net WPF

Is the React Native component hierarchy documented anywhere? If so, where or how?

I can't find any inheritance diagrams (or any documentation at all) of what components inherit from.
For instance, it seems that TouchableWithoutFeedback is the parent superclass of TouchableHighlight and TouchableOpacity (because TouchableWithoutFeedback contains the methods onPressIn and onPressOut).
I'm looking for something like the bottom half of this inheritance chain documentation (for a different technology) that lists all the superclass methods.
You'll have to dive into the source code. But as a guide, no component inherits from any other Component. Every component just extends Component or maybe PureComponent.
For instance here is TouchableNativeFeedback - https://github.com/facebook/react-native/blob/b7bb2e5745f2bdbfeeccef8d97d469730942e01c/Libraries/Components/Touchable/TouchableNativeFeedback.android.js
Yes some of the props are shared between components, like View ScrollView. And as you mentioend above. but this is not due to inheritance. The docs make this clear by using spread operator on props. For instance:
The text component: https://facebook.github.io/react-native/docs/text.html#style
Has same style properties as View as indicatated by View Style Props...:
Same with the TouchableNativeFeedback it has TouchableWithoutFeedback props... - https://facebook.github.io/react-native/docs/touchablenativefeedback.html#props :

Aurelia page life-cycle

I had a problem with Aurelia's binding system. I want so.e clarification on how view and viewmodels interact.
Lets say I have a div. This div has child divs that get generated by Aurelia's "repeat.for". I then have a function that does something to the parent div and its children. Where or when do I call this function. From experience, I cant call the function in the attached() hook because Aurelia's binding system is asynchronous so not all child divs may be ready by the time I call my function

Difficulty in deciding where to put the code in yii view helper

I'm new to yii development.
In my system I'm trying to create a submenu system. The submenu will be shown based on the
controller. The submenu will be separate views, that I'll load in main layout.
I want to separate the logic of loading the submenu view from the main layout. But, I'm not sure where to write it.
Does Yii has view helpers like in RoR. Or, should I write it as a component?
Please give suggestions.
Thanks.
I'd just create a component for this, and instantiate that with the relevant menu options from the controllers. If present in all controllers, implement support in a BaseController and just set up an array of items in the child controllers.
Your default generated Yii application has a parent Controller in protected/components/Controller.php. If you need to access additional parameters in layout, add public properties to Controller, set them in your child controller, and use them in your view/layout files.
In your case, add a function to this parent Controller that returns a rendered submenu (with a renderPartial call for example) and call this function from your layout.

Application Design Question

I have an application that uses a UITabBarController as its outer container. Each tab uses a UINavigationController for its root view controller. I employ a multi-button toolbar as the navigation bar's right bar button. Some of these toolbar buttons are universal to the application; some pertain to individual tabs.
My instinct is to create a base view controller class with all universal toolbar construction and implementation code, then have each of my root view controllers inherit from this base class. If they want to add additional buttons to the toolbar, they simply need to override the toolbar construction method (where I'll centralize the construction of the tool bar), and add the implementation code for the additional buttons.
Sounds good in theory, but since I'm new to Objective-C, I welcome any additional input/advice from more experienced developers.
If you have a enough reusable code in your "toolbar construction and implementation " to motivate you to implement a base class and reuse it on your child classes, then it actually sounds like a good solutions.
One thing that you should analyze is which class would you extend: UIViewController or UIToolBar.
If you just want a custom reusable toolbar that only changes some visual properties (like the label of a the left button, or let the right button visible or not, etc..), maybe the best approach is to implement a base class that extends from UIToolBar, and then use it in your view controllers.
But if you have a considerable complex logic handling actions from the buttons of the toolbar, or any "heavy code" beyond simple visual property settings, the creation of a base class that extends UIViewController sounds like a better approach.
The better choise is up to you and to what you want to implement/reuse.
Good luck!