-
FEATURED COMPONENTS
First time here? Check out the FAQ!
After compilation this Doc-Page my HelloZK looks like:
<window id="win" border="normal" width="600px" xmlns:w="http://www.zkoss.org/2005/zk/client"> <textbox id="textToEval" value ="1+2" onChanging="resultLabel.value=event.value"/> <label value=" Hello ZKalkulator! Just try to edit expression in the text field to get result..." id="resultLabel"> <attribute w:name="setValue"> function (value) { this.$setValue(value); //call the original method if (this.desktop) { this._flag = !this._flag; this.setStyle('background:'+(this._flag ? 'red':'green')); this.$setValue( eval ( ''+value+'') ) ; } } </attribute> </label> </window>
So, its works (WONDERFULL even on ONLINE_DEMO!) as good as should...
.. till expr-eval-error. How can i process wrong expression-evaluation otherwise?
Hi vpupkin
Why are you need do this ?
this.$setValue( eval ( ''+value+'') ) ;
You can set the result into value
<attribute w:name="setValue"> function (value) { this.$setValue(value); //call the original method if (this.desktop) { this._flag = !this._flag; this.setStyle('background:'+(this._flag ? 'red':'green')); val value; try{ value = eval ( ''+value+'') }catch(e){} this.$setValue(value) ; } } </attribute>
I use ZK5
this feature only exits in ZK 5
Sorry I have wrong words
try this in ZK demo
<window id="win" border="normal" width="600px" xmlns:w="http://www.zkoss.org/2005/zk/client"> <textbox id="textToEval" value ="1+2" onChanging="resultLabel.value=event.value"/> <label value=" Hello ZKalkulator! Just try to edit expression in the text field to get result..." id="resultLabel"> <attribute w:name="setValue"> function (value) { this.$setValue(value); //call the original method if (this.desktop) { this._flag = !this._flag; this.setStyle('background:'+(this._flag ? 'red':'green')); var value; try{ value = eval ( ''+value+''); }catch(e){} this.$setValue(value) ; } } </attribute> </label> </window>
WOW! It's works now! Great. 10x a lot!
Asked: 2010-08-24 14:07:49 +0800
Seen: 745 times
Last updated: Sep 13 '10