# model binding

18691 1 10 129

Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3468721

By: nobody

Hi. How should I reflect my changes to the view back to the model?

Here is my hello.zul file. I have a controller called testWindow. My model is an attribute of my controller. The model is a simple Person bean with sets and gets for name. The textbox shows the name correctly. However I would like changes to the value in the textbox to be reflected back to the model. How can this be done?

<window id="testWindow" title="Window" border="normal" width="600px"
use="bonzi.TestWindow">
<hbox>
Name:
<textbox id="name" value="${testWindow.person.name}"> </textbox> </hbox> <button label="Hello"><attribute name="onClick">testWindow.onHello();</attribute></button> </window> Andrew delete retag edit ## 1 Reply Sort by » oldest newest answered 2005-12-12 01:26:04 +0800 admin 18691 1 10 129 Orignial message at: https://sourceforge.net/forum/message.php?msg_id=3470454 By: henrichen Hi! Andrew, The ZK's programming model is event-driven. i.e. the ZK engine would send(post) events triggered by end users (at browser) to event handlers (at server) written by programmers. In your case, you should write an event handler to listen to event "onChange" of the textbox with id == "name". <textbox id="name" value="${testWindow.person.name}" onChange="testWindow.person.name = self.value"> </textbox>

the "self" in the handler means the "textbox" component itself.

There are at least three ways to register an event handler to an event. Please take a look of the userguide (http://zk1.sourceforge.net/wp/ZK-userguide.pdf).
And we have setup a wikibooks about ZK's How-Tos (http://en.wikibooks.org/wiki/ZK:_How-Tos). Should there were other questions, please check it first. Though it is kind of slim right now :-); we invite you the users to contribute and share your ZK How-Tos.

Henri

[hide preview]