0

zk 8.6.0.1 custom constraint problem

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

filippoluchini gravatar image filippoluchini
1

Hello, I'm migrating from zk 7.0.8.1 to 8.6.0.1 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) {
        super(constraints);
    }

    public TestConstraint(int flags) {
        super(flags);
    }

    @Override
    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.

Filippo

delete flag offensive retag edit

2 Answers

Sort by » oldest newest most voted
0

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

cor3000 gravatar image cor3000
4332 1 7
ZK Team

updated 2019-01-10 17:27:01 +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

link publish delete flag offensive edit
0

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

filippoluchini gravatar image filippoluchini
1

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

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

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

Seen: 6 times

Last updated: Jan 10

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