Wire Event Listeners"

From Documentation
(make warning red)
(remove red color)
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. Then we can use <tt> @Listen</tt> to declare a method as an event listener.  <span style="color:#FF0000">'''We don't recommend this usage'''</span> because it loses the ViewModel an important advantage: loosely coupling with View. '''Please evaluate trade-off before using it.'''
+
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. Then we can use <tt> @Listen</tt> to declare a method as an event listener.  '''We don't recommend this usage''' because it loses the ViewModel an important advantage: loosely coupling with View. '''Please evaluate trade-off before using it.'''
  
  

Revision as of 02:08, 29 May 2012


Wire Event Listeners



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. Then we can use @Listen to declare a method as an event listener. We don't recommend this usage because it loses the ViewModel an important advantage: loosely coupling with View. Please evaluate trade-off 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

Last Update : 2012/05/29


Version Date Content
6.0.0 May 2012 Supplement




Last Update : 2012/05/29

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.