0

Using multiple custom constraints

asked 2013-06-12 13:02:53 +0800

Doychev gravatar image Doychev
6

updated 2013-06-12 14:11:48 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Hello,

I need to validate several fields using more than one custom constraint. In addition, I would also like to pass parameters to the constraints (if that is possible). So far, the validation was working like:

<textbox constraint="${c:new('com.sample.constraints.FirstCustomConstraint') }"/>

Now I need something like this:

<textbox constraint="${c:new('com.sample.constraints.FirstCustomConstraint') }, ${c:new('com.sample.constraints.SecondCustomConstraint(123)') }, "/>

How can this be done?

(I am using ZK 5)

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-06-13 09:17:18 +0800

Doychev gravatar image Doychev
6

In a further research, I found these:

zkoss.org/javadoc/5.0.11/zk/org/zkoss/xel/fn/CommonFns.html#new_%28java.lang.Object,%20java.lang.Object%29

books.zkoss.org/wiki/ZUML%20Reference/EL%20Expressions/Core%20Methods/new

The suggestion in it:

${c:new('foo.Mine', 10)}

for the second part of my question, doesn't work though. I get a message:

The function "c:new" requires 1 arguments but was passed 2

Caused by:

org.zkoss.xel.XelException: The function "c:new" requires 1 arguments but was passed 

...
link publish delete flag offensive edit
0

answered 2013-07-03 08:01:58 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

You should use

${c:new2('foo.Mine', 10);

Here is the declaration:

<function>
    <name>new</name>
    <function-class>org.zkoss.xel.fn.CommonFns</function-class>
    <function-signature>java.lang.Object new_(java.lang.Object)</function-signature>
    <description>
Instantiates the specified class.
The parameter could be either a string (class name) or a Class instance.
    </description>
</function>
<function>
    <name>new1</name>
    <function-class>org.zkoss.xel.fn.CommonFns</function-class>
    <function-signature>java.lang.Object new_(java.lang.Object, java.lang.Object)</function-signature>
    <description>
Instantiates the specified class and argument.
The first parameter could be either a string (class name) or a Class instance.
The second parameter is the argument passed to the constructor.
    </description>
</function>
<function>
    <name>new2</name>
    <function-class>org.zkoss.xel.fn.CommonFns</function-class>
    <function-signature>java.lang.Object new_(java.lang.Object, java.lang.Object, java.lang.Object)</function-signature>
    <description>
Instantiates the specified class and two arguments.
The first parameter could be either a string (class name) or a Class instance.
The second parameter is the first argument passed to the constructor.
The third parameter is the second argument passed to the constructor.
    </description>
</function>
<function>
    <name>new3</name>
    <function-class>org.zkoss.xel.fn.CommonFns</function-class>
    <function-signature>java.lang.Object new_(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)</function-signature>
    <description>
Instantiates the specified class and three arguments.
The first parameter could be either a string (class name) or a Class instance.
The second parameter is the first argument passed to the constructor.
The third parameter is the second argument passed to the constructor.
The fourth parameter is the third argument passed to the constructor.
    </description>
</function>
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
2 followers

RSS

Stats

Asked: 2013-06-12 13:02:53 +0800

Seen: 73 times

Last updated: Jul 03 '13

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