0

bug zk 5.01

asked 2010-03-29 11:04:37 +0800

pymsoft gravatar image pymsoft
133 5

in Decimalbox when I get the value myDecimalbox.getValue() loss the scale (I use 3 decimals) and the scale remains in "0" and when if try to save a value of 123.456 ( myVar = myDecimalbox.getvalue() ) I obtain 123456

Any idea?

thank you

Pedro Gonzalez

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-03-29 18:29:55 +0800

pymsoft gravatar image pymsoft
133 5

updated 2010-03-29 18:55:52 +0800

the error is in toNumberOnly(value)

my value is 44.553 and toNumberOnly set a scale of "0" (the scale is "3")

the error is when i don't touch the decimalbox...

Decimalbox.java

protected Object coerceFromString(String value) throws WrongValueException {
		final Object[] vals = toNumberOnly(value);
		final String val = (String)vals[0];
		if (val == null || val.length() == 0)
			return null;

		try {
			BigDecimal v = new BigDecimal(val);
			if (_scale != AUTO)
				v = v.setScale(_scale, getRoundingMode());

			int divscale = vals[1] != null ? ((Integer)vals[1]).intValue(): 0;
			if (divscale > 0) {
				final BigDecimal ten = new BigDecimal(10);
				do {
					v = v.divide(ten, _scale == AUTO ? v.scale()+1: _scale,


or maybe the error is in the file: InputElement.java

-->> same = Objects.equals(_value, val);
_value = 44.553
val = 44553

obviously not same, but i'dont change it

public void setText(String value) throws WrongValueException {
		if (_maxlength > 0 && value != null && value.length() > _maxlength)
			throw showCustomError(
				new WrongValueException(this, MZul.STRING_TOO_LONG, new Integer(_maxlength)));

		final Object val = coerceFromString(value);
		final boolean same = Objects.equals(_value, val);
		boolean errFound = false;
		if (!same || !_valided || _errmsg != null) { //note: the first time (!_valided) must always validate
			validate(val); //Bug 2946917: don't validate if not changed

			errFound = _errmsg != null;
			clearErrorMessage(); //no error at all
		}


this is my code in the file .zul

<decimalbox id="arcostoult" cols="10"
constraint="no negative" maxlength="9"
action="onkeyup:#{self}.value = #{self}.value.replace('.',',');" />


any idea?


thank you

Pedro Gonzalez

link publish delete flag offensive edit

answered 2010-03-30 12:05:24 +0800

pymsoft gravatar image pymsoft
133 5

my number is formatted like this: 149,50

if I modify the number (Decimalbox), not problem.

if I don't modify the number, when I get the value arcostoult.getValue() this value change for 14950

the problem I think is the "," like decimal...

then, the error is in toNumberOnly(value)

please, help...

Pedro Gonzalez

link publish delete flag offensive edit

answered 2010-04-12 08:22:58 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Push

link publish delete flag offensive edit

answered 2010-04-15 20:24:14 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

@Pedro Gonzalez,

Please post to ZK bugs so we can track it. Thanks.

link publish delete flag offensive edit

answered 2010-04-16 10:52:37 +0800

pymsoft gravatar image pymsoft
133 5

done


regards.

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: 2010-03-29 11:04:37 +0800

Seen: 447 times

Last updated: Apr 16 '10

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