Revision history [back]

click to hide/show revision 1
initial version

answered 2015-12-09 09:30:24 +0800

WilliamB gravatar image WilliamB

OK Chill, first thanks for sticking around ;)

If I used the constructor with only the regex, it works fine.

setConstraint(new SimpleConstraint(regex));

The issue with the message triggering all the time is when I add a custom error message by using the 2 argument contructor

setConstraint(new SimpleConstraint(regex, "toto"));

Tried adding ":" at the end of the regex, like when it's in the zul, to see if it helped but it didn't.

So now i'm dwelling into ZK code to see where the issue comes from and create an issue ...

OK Chill, first thanks for sticking around ;)

I finally found what is causing the issue : If I used use the constructor with only the regex, it works fine.

setConstraint(new SimpleConstraint(regex));

The issue with the message triggering all the time is when I add a custom error message by using the 2 argument arguments contructor

setConstraint(new SimpleConstraint(regex, "toto"));

Tried adding ":" at the end of the regex, like when it's in the zul, to see if it helped but it didn't.

Looking into the code it doesn't work the same way to generate the pattern through both constructor.

So now i'm dwelling into ZK code to see where the issue comes from and create an issue ...

OK Chill, first thanks for sticking around ;)

I finally found what is causing the issue : If I use the constructor with only the regex, it works fine.

setConstraint(new SimpleConstraint(regex));

The issue with the message triggering all the time is when I add a custom error message by using the 2 arguments contructor

setConstraint(new SimpleConstraint(regex, "toto"));

Tried adding ":" at the end of the regex, like when it's in the zul, to see if it helped but it didn't.

Looking into the code it doesn't work the same way to generate the pattern through both constructor.

So now i'm dwelling into ZK code to see where the issue comes from and create an issue ...

EDIT: Here what I found out :

  1. If I use : public SimpleConstraint(String constraint)

_raw: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : null

public String getClientConstraint() : '/^([0-9]{1,3}(,[0-9]{1,2})?)?$/'

  1. If I use public SimpleConstraint(String regex, String errmsg) with wrapping "/"

_raw: null

_regex: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/

_errmsg : myMsg

public String getClientConstraint() : new zul.inp.SimpleConstraint(0,'/^([0-9]{1,3}(,[0-9]{1,2})?)?$/','myMsg')

  1. If I use public SimpleConstraint(String regex, String errmsg) without wrapping "/"

_raw: null

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : myMsg

public String getClientConstraint() : new zul.inp.SimpleConstraint(0,'^([0-9]{1,3}(,[0-9]{1,2})?)?$','myMsg')

The last 2 do NOT work on the front (JS) side, they ALWAYS trigger even when the value match the regex. The first works fine but I don't have my own error message.

OK Chill, first thanks for sticking around ;)

I finally found what is causing the issue : If I use the constructor with only the regex, it works fine.

setConstraint(new SimpleConstraint(regex));

The issue with the message triggering all the time is when I add a custom error message by using the 2 arguments contructor

setConstraint(new SimpleConstraint(regex, "toto"));

Tried adding ":" at the end of the regex, like when it's in the zul, to see if it helped but it didn't.

Looking into the code it doesn't work the same way to generate the pattern through both constructor.

So now i'm dwelling into ZK code to see where the issue comes from and create an issue ...

EDIT: Here what I found out :

    • If I use : public SimpleConstraint(String constraint)

_raw: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : null

public String getClientConstraint() : '/^([0-9]{1,3}(,[0-9]{1,2})?)?$/'

    • If I use public SimpleConstraint(String regex, String errmsg) with wrapping "/"

_raw: null

_regex: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/

_errmsg : myMsg

public String getClientConstraint() : new zul.inp.SimpleConstraint(0,'/^([0-9]{1,3}(,[0-9]{1,2})?)?$/','myMsg')

    • If I use public SimpleConstraint(String regex, String errmsg) without wrapping "/"

_raw: null

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : myMsg

public String getClientConstraint() : new zul.inp.SimpleConstraint(0,'^([0-9]{1,3}(,[0-9]{1,2})?)?$','myMsg')

The last 2 do NOT work on the front (JS) side, they ALWAYS trigger even when the value match the regex. The first works fine but I don't have my own error message.

OK Chill, first thanks for sticking around ;)

I finally found what is causing the issue : If I use the constructor with only the regex, it works fine.

setConstraint(new SimpleConstraint(regex));

The issue with the message triggering all the time is when I add a custom error message by using the 2 arguments contructor

setConstraint(new SimpleConstraint(regex, "toto"));

Tried adding ":" at the end of the regex, like when it's in the zul, to see if it helped but it didn't.

Looking into the code it doesn't work the same way to generate the pattern through both constructor.

So now i'm dwelling into ZK code to see where the issue comes from and create an issue ...

EDIT: Here what I found out :

  • If I use : public SimpleConstraint(String constraint)

_raw: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : null

public String getClientConstraint() : '/^([0-9]{1,3}(,[0-9]{1,2})?)?$/'

  • If I use public SimpleConstraint(String regex, String errmsg) with wrapping "/"

_raw: null

_regex: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/

_errmsg : myMsg

public String getClientConstraint() : new zul.inp.SimpleConstraint(0,'/^([0-9]{1,3}(,[0-9]{1,2})?)?$/','myMsg')

  • If I use public SimpleConstraint(String regex, String errmsg) without wrapping "/"

_raw: null

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : myMsg

public String getClientConstraint() : new zul.inp.SimpleConstraint(0,'^([0-9]{1,3}(,[0-9]{1,2})?)?$','myMsg')

The last 2 do NOT work on the front (JS) side, they ALWAYS trigger even when the value match the regex. The first works fine but I don't have my own error message.

  • If I use public SimpleConstraint(String regex) with my error message following the regex and ":"

_raw: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/:myMsg

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : myMsg

public String getClientConstraint() : '/^([0-9]{1,3}(,[0-9]{1,2})?)?$/:myMsg'

OK Chill, first thanks for sticking around ;)

I finally found what is causing the issue : If I use the constructor with only the regex, it works fine.

setConstraint(new SimpleConstraint(regex));

The issue with the message triggering all the time is when I add a custom error message by using the 2 arguments contructor

setConstraint(new SimpleConstraint(regex, "toto"));

Tried adding ":" at the end of the regex, like when it's in the zul, to see if it helped but it didn't.

Looking into the code it doesn't work the same way to generate the pattern through both constructor.

So now i'm dwelling into ZK code to see where the issue comes from and create an issue ...

EDIT: Here what I found out :

  • If I use : public SimpleConstraint(String constraint)

_raw: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : null

public String getClientConstraint() : '/^([0-9]{1,3}(,[0-9]{1,2})?)?$/'

  • If I use public SimpleConstraint(String regex, String errmsg) with wrapping "/"

_raw: null

_regex: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/

_errmsg : myMsg

public String getClientConstraint() : new zul.inp.SimpleConstraint(0,'/^([0-9]{1,3}(,[0-9]{1,2})?)?$/','myMsg')

  • If I use public SimpleConstraint(String regex, String errmsg) without wrapping "/"

_raw: null

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : myMsg

public String getClientConstraint() : new zul.inp.SimpleConstraint(0,'^([0-9]{1,3}(,[0-9]{1,2})?)?$','myMsg')

The last 2 do NOT work on the front (JS) side, they ALWAYS trigger even when the value match the regex. The first works fine but I don't have my own error message.

So to get it to work I've to use the same way it's used when calling from zul :

  • If I use public SimpleConstraint(String regex) with my error message following the regex and ":"

_raw: /^([0-9]{1,3}(,[0-9]{1,2})?)?$/:myMsg

_regex: ^([0-9]{1,3}(,[0-9]{1,2})?)?$

_errmsg : myMsg

public String getClientConstraint() : '/^([0-9]{1,3}(,[0-9]{1,2})?)?$/:myMsg'

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