zk custom constraint problem [closed]

asked 2019-01-08 16:01:26 +0800

filippoluchini gravatar image filippoluchini
101 2

Hello, I'm migrating from zk to and I'm facing some problems with custom constraints. I try to make a simple example that works with zk7 and doesn't work with zk8.

I'have a TestConstraint class that extends SimpleConstraint, like this:

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zul.SimpleConstraint;

public class TestConstraint extends SimpleConstraint {
    private static final long serialVersionUID = 694308029327860534L;

    public TestConstraint(String constraints) {

    public TestConstraint(int flags) {

    public void validate(Component comp, Object value) throws WrongValueException {
        super.validate(comp, value);

In the VM I declare and instantiate my two simple constraints for having no empty values in my input element:

private transient TestConstraint constraintByString;
private transient TestConstraint constraintByFlag;

public TestConstraint getConstraintByString() {
    if (constraintByString == null) {
        constraintByString = new TestConstraint("no empty");
    return constraintByString;

public TestConstraint getConstraintByFlag() {
    if (constraintByFlag == null) {
        constraintByFlag = new TestConstraint(256);
    return constraintByFlag;

In the zul I use these constraints for two datebox:

<datebox value="@bind(vm.start)"
format="dd/MM/yyyy HH:mm:ss" cols="19"
constraint="${vm.constraintByString}" />

<datebox value="@bind(vm.start)"
format="dd/MM/yyyy HH:mm:ss" cols="19"
constraint="${vm.constraintByFlag}" />

With zk7 both the constraints work; with zk8 the first one works, the second one doesn't work. What am I doing wrong?

Thanks in advance.


delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by cor3000
close date 2019-01-31 11:06:02

2 Answers

Sort by » oldest newest most voted

answered 2019-01-10 17:23:58 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2019-01-28 12:14:00 +0800

thanks for posting this issue. I simplified the problem and posted the JIRA issue ZK-4190

A workaround is also provided in JIRA and can be applied to a zul file as in this example

UPDATE: ZK-4190 has been fixed in the latest FL version 8.6.1.FL.20190125

link publish delete flag offensive edit

answered 2019-01-10 19:42:35 +0800

filippoluchini gravatar image filippoluchini
101 2

Sorry @cor3000, yesterday I posted this JIRA issue ZK-4187!

link publish delete flag offensive edit


we noticed and marked them as duplicates (no harm caused). next time if you mention the JIRA ID here, we'll find it more easily.

cor3000 ( 2019-01-28 12:06:33 +0800 )edit

Question tools

1 follower



Asked: 2019-01-08 16:01:26 +0800

Seen: 13 times

Last updated: Jan 28 '19

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