Wire Event Listeners"

From Documentation
Line 3: Line 3:
  
 
{{Template:UnderConstruction}}
 
{{Template:UnderConstruction}}
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.
+
 
 +
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 suggest this usage'''</span> because it loses the ViewModel an important advantage: loosely coupling with View. '''Please evaluate trade-off before using it.'''
  
  

Revision as of 01:43, 29 May 2012


Wire Event Listeners



WarningTriangle-32x32.png This page is under construction, so we cannot guarantee the accuracy of the content!

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 suggest 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.