Revision history [back]

click to hide/show revision 1
initial version

answered 2015-05-15 14:14:16 +0800

Worsik gravatar image Worsik

I think that all maxlength functionality is wrong in ZK. For example when you need to show a form with values from different source. When these values exceed maxlength, your form will not appear and WrongValueException is thrown. That's why I use my own maxlength validation. I am using my own Constraints which can handle more validation requirements than only one. I have constraint which throws MandatoryFieldException, MaxLengthException and InvalidFormatException in method validateThrowing(). This method is then called from method validate(), where I can handle my own reaction on validation error. For example highlight invalid inputs. Then my form is shown even if values are not valid. Bad thing is that you are not stopped from writing when you exceed max length limit.

I had similar problem and now for BigDecimal I use generated maxvalue for compare. For example when you have maxlength 13 and your decimal has scale 4, then you generate string from "." appending 4 * '9' and prepending '9' to total length 13.

I think that all maxlength functionality is wrong in ZK. For example when you need to show a form with values from different source. When these values exceed maxlength, your form will not appear and WrongValueException is thrown. That's why I use my own maxlength validation. I am using my own Constraints which can handle more validation requirements than only one. I have constraint which throws MandatoryFieldException, MaxLengthException and InvalidFormatException in method validateThrowing(). This method is then called from method validate(), where I can handle my own reaction on validation error. For example highlight invalid inputs. Then my form is shown even if values are not valid. Bad thing is that you are not stopped from writing when you exceed max length limit.

I had similar problem and now for BigDecimal I use generated maxvalue for compare. For example when you have maxlength 13 and your decimal has scale 4, then you generate string from "." appending 4 * '9' and prepending '9' to total length 13.

OMG, I just realized that this is soooo old question... Sorry for that

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