Bean Cross validation for plugins ?

Plugins and scripts contributed by QuickBuild users

Bean Cross validation for plugins ?

Postby benprim » Thu Dec 15, 2016 10:48 am

So I have an optional field in one of my plugins and needs to be filled only if another field is set
I tried implementing a class level constraint ... but it doesn't look like been checked.
If I change my constraint to a method level contraint it works.
... i'm no bean expert so may miss something, but I don't know either if it can come from a Quickbuild limitation...

Thanks a lot :)
benprim
 
Posts: 84
Joined: Wed Dec 14, 2011 8:22 am

Re: Bean Cross validation for plugins ?

Postby robinshen » Fri Dec 16, 2016 12:32 am

You may have your bean implementing Validatable interface, and then in the validate method do the mutual validation. The SystemSetting class in QB source code provides an example for that.
robinshen
Site Admin
 
Posts: 6169
Joined: Thu Jul 24, 2003 9:53 pm

Re: Bean Cross validation for plugins ?

Postby benprim » Mon Dec 19, 2016 1:35 pm

Thanks a lot Robin !
Works like a charm :)
By the way, is there a way to toggle the display of a field only if another one is enabled ?
benprim
 
Posts: 84
Joined: Wed Dec 14, 2011 8:22 am

Re: Bean Cross validation for plugins ?

Postby robinshen » Tue Dec 20, 2016 1:26 am

You may design a child bean to include the dependent field, and once the child bean is enabled, then you can continue to edit the field in that child bean.
robinshen
Site Admin
 
Posts: 6169
Joined: Thu Jul 24, 2003 9:53 pm

Re: Bean Cross validation for plugins ?

Postby benprim » Wed Dec 21, 2016 8:37 am

Great thanks Robin !
benprim
 
Posts: 84
Joined: Wed Dec 14, 2011 8:22 am


Return to QuickBuild Plugins and Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron