0

Decimalbox coerceFromString

asked 2012-06-01 13:34:13 +0800

mbarbieri gravatar image mbarbieri
93 1
www.ste-energy.com

Hi,
I don't know if it's a bug or a change that has been made on purpose, so I first ask here.
In my application I have several Decimalboxes where I need that ',' and '.' (comma and point) have the same behavior.
Back in ZK3.6 I redefined my own Decimalbox class in lang-addon.xml and override the

protected Object coerceFromString(String value)

method to substitute the comma with a point and all worked fine.
Now with ZK6 it seems that this method is never called...
Is this component behavior changed somehow?
Thank you,
Bye

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2012-06-01 13:38:38 +0800

mbarbieri gravatar image mbarbieri
93 1
www.ste-energy.com

just for the sake of it, here it is a sample code:

<zscript>
        public class MyDecimalbox extends org.zkoss.zul.Decimalbox {
            public MyDecimalbox() {
                System.out.println("Constructor called!");
            }

            protected Object coerceFromString(String value) {
                System.out.println("NEVER CALLED!");
            }
        }
    </zscript>

    <decimalbox use="MyDecimalbox" format="0.00"/>

link publish delete flag offensive edit

answered 2012-06-04 08:07:56 +0800

paowang gravatar image paowang
140 6

Since 5.0.0, ZK introduces "Server+Client Fusion": http://books.zkoss.org/wiki/Small_Talks/2009/July/ZK_5.0_and_Server%2BClient_Fusion
I think that Decimalbox check format on client-side not server-side.

If you want to change the value before Decimalbox apply it, you can use client-size programming: http://books.zkoss.org/wiki/ZK%20Client-side%20Reference/General%20Control/Widget%20Customization

I write a example:

<zk xmlns:w="http://www.zkoss.org/2005/zk/client">
	<decimalbox format="0.00">
		 <attribute w:name="coerceFromString_">
            function (value) {
            	console.log(value);
            	return this.$coerceFromString_(value);
            }
            </attribute>
	</decimalbox>
</zk>

link publish delete flag offensive edit

answered 2012-06-04 10:11:59 +0800

mbarbieri gravatar image mbarbieri
93 1
www.ste-energy.com

Thank you, works great!
Suggestion: shouldn't the coerceFromString Java method be removed as ZK is not using it?
Thank you again,
bye

link publish delete flag offensive edit

answered 2012-06-07 06:32:41 +0800

paowang gravatar image paowang
140 6

I think that the coerceFromString java method might be used in some cases.
:D

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: 2012-06-01 13:34:13 +0800

Seen: 170 times

Last updated: Jun 07 '12

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