zk custom constraint problem

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

filippoluchini gravatar image filippoluchini

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

2 Answers

Sort by » oldest newest most voted

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

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

filippoluchini gravatar image filippoluchini

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

1 follower



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

Seen: 6 times

Last updated: Jan 10

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