Wire Components"
From Documentation
(Created page with "{{ZKDevelopersReferencePageHeader}} Although the original design principle of MVVM patter is that ViewModel doesn't have any reference to UI components, ZK provide ways to retr...") |
|||
Line 22: | Line 22: | ||
</source> | </source> | ||
* Use <tt> @ContextParam(ContextType.VIEW) </tt> to retrieve root component. (line 11) | * Use <tt> @ContextParam(ContextType.VIEW) </tt> to retrieve root component. (line 11) | ||
+ | |||
+ | |||
+ | |||
+ | =Version History= | ||
+ | {{LastUpdated}} | ||
+ | {| border='1px' | width="100%" | ||
+ | ! Version !! Date !! Content | ||
+ | |- | ||
+ | | 6.0.0 | ||
+ | | February 2012 | ||
+ | | The MVVM was introduced. | ||
+ | |} | ||
{{ZKDevelopersReferencePageFooter}} | {{ZKDevelopersReferencePageFooter}} |
Revision as of 01:45, 9 February 2012
Although the original design principle of MVVM patter is that ViewModel doesn't have any reference to UI components, ZK provide ways to retrieve UI components on a ZUL in a ViewModel. One is passing components as parameters in binding expression. Another is to wire components by Selector. This way enables you to wire components with @Wire like you do in a SelectorComposer. Before doing this, you have to call Selectors.wireComponents() manually and pass the root component in initial method.
Example to wire components in a ViewModel
public class SearchAutowireVM{
//UI component
@Wire("#msgPopup")
Popup popup;
@Wire("#msg")
Label msg;
@Init
public void init(@ContextParam(ContextType.VIEW) Component view){
Selectors.wireComponents(view, this, false);
}
}
- Use @ContextParam(ContextType.VIEW) to retrieve root component. (line 11)
Version History
Version | Date | Content |
---|---|---|
6.0.0 | February 2012 | The MVVM was introduced. |