0

Problems with onChanging event

asked 2006-02-28 22:32:01 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

By: nobody

The event in itself is fine (you're probably using the onkeyup javascript event).
However, you should make it so, or add a support for a short delay. Right now, whenever I hit a key, a request is sent to the server. So, for example, when I'm typing really fast, multiple requests are being sent, so the text in the other box is getting typed out even after I finished typing (this would probably look worse on dial-up connections).

What you should do is not send any requests before, let's say, 500 ms passes.
So, the user types very fast, and then halts, half a second passes, and only then the request is sent. Saves the server some bandwidth, and you're also avoiding the risk of the browser breaking down.

If you need support on this I can help, since I've implemented this same thing just recently in Javascript :)

Csaba

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2006-03-01 06:18:26 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

By: tomyeh

We actually use a timer to scan whether it is changed, once the component got focus.

Maybe the interval is too small (150ms). You might take a look at widget.js in zul.jar. I love to hear your comment.

link publish delete flag offensive edit

answered 2006-03-01 10:51:44 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

By: gcsaba2

Changing the timer to 500 ms seems to have did the trick. Now the event doesn't happen "immediately", but there's a noticable difference between loading all the city names starting with "a" and "ams" :)

link publish delete flag offensive edit

answered 2007-01-15 12:34:09 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

By: rainermichael

Hi,

I want to create a Textbox where the numbers of char are shown in another textbox that the user has entered so far. The textbox should be updated every time the usere enterd a new character in the first textbox.
I tried to rely on the onChanging event and expected that this event is fired every time the user enters a char in the textbox. But this didn't happend. The onCanging event behave like the onChange Event. Only if the user leaves the component (onBlur) the Event is fired.

<x:row><x:label zk:value="${pindex.polltext}"/><x:vbox><span class="smallfont">Max.
255 Zeichen</span><x:textbox zk:onChange="onChanging()" zk:id="quest" zk:rows="5"
zk:cols="40" zk:maxlength="255"></x:textbox><x:textbox zk:id="chars"
zk:disabled="true" zk:cols="4"/></x:vbox></x:row> <zk:zscript> void onChanging(){ String text = (String) quest.getValue(); int len = text.length(); chars.setValue(len+"");
}
</zk:zscript>

Regards
Michael

link publish delete flag offensive edit

answered 2007-01-15 13:09:07 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

By: rainermichael

Sorry,
I got it.

<zk:zscript>
void onChanging(){
String text = (String) event.getValue(); int len = text.length(); chars.setValue(len+"");
}
</zk:zscript>

link publish delete flag offensive edit

answered 2007-01-15 22:18:44 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

By: perolesen

I'm rather new to ZK so forgive me if I'm wrong...

Can it be that listening in the way you do (using onChange="..." on the element) does not produce an ASAP event/listener? You could try doing this instead:

<x:textbox zk:onChange="onChanging()" zk:id="quest" zk:rows="5" zk:cols="40"
zk:maxlength="255"></x:textbox>

<zscript>
quest.addEventListener("onChanging", new EventListener() {
public boolean isAsap() {
return true;
}
public void onEvent(Event event) {
text = quest.getValue();
len = text.length();
chars.setValue(len+"");
}
});
</zscript>



link publish delete flag offensive edit

answered 2007-01-16 02:15:42 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

By: henrichen

Will your code work?

<x:textbox zk:onChanging="doChanging()" ....>

/henri



link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2006-02-28 22:32:01 +0800

Seen: 1,170 times

Last updated: Jan 16 '07

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More