Wire Event Listeners"
From Documentation
(remove red color) |
m |
||
Line 3: | Line 3: | ||
− | To wire event listeners in a ViewModel like [[ZK Developer's Reference/MVC/Controller/Wire Event Listeners]], we have to call <tt> Selectors.wireEventListeners() </tt> in the initial method. | + | To wire event listeners in a ViewModel like [[ZK Developer's Reference/MVC/Controller/Wire Event Listeners]], we have to call <tt> Selectors.wireEventListeners() </tt> in the initial method. We then can use <tt> @Listen</tt> to declare a method as an event listener. '''We do not recommend this usage''' because it loses <b>ViewModel</b> an important advantage i.e. loose coupling with View. '''Please evaluate the trade-offs before using it.''' |
Revision as of 03:16, 30 May 2012
To wire event listeners in a ViewModel like ZK Developer's Reference/MVC/Controller/Wire Event Listeners, we have to call Selectors.wireEventListeners() in the initial method. We then can use @Listen to declare a method as an event listener. We do not recommend this usage because it loses ViewModel an important advantage i.e. loose coupling with View. Please evaluate the trade-offs before using it.
Wire event listener in a ViewModel
public class SearchAutowireVM{
@Init
public void init(@ContextParam(ContextType.VIEW) Component view){
Selectors.wireEventListeners(view, this);
}
@Listen("onClick=#mybutton")
public void submit(MouseEvent event){
//handle events
}
}
- Selectors.wireEventListeners() 's first parameters is Root View Component which can be retrieved by @ContextParam.
Version History
Version | Date | Content |
---|---|---|
6.0.0 | May 2012 | Supplement |