Quantcast

custom error message for constraints

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

custom error message for constraints

adwin grails

Hi,

I have domain with constraints like min value must greater than 0

I have no idea how to change the message if the constraints are not passed.

which file i need to edit to do that ?

I also need to display the values some properties as well .. like

"you cannot make any transaction because your balance is less than 100. Your current balance is ${currentBalance}. Your current balance is ${lastBalance} and amount that need to be deducted ${deductedValue} "  


note: my class Transaction has properties: lastBalance, deductedValue, currentBalance

the currentBalance has min(100) constraints

at the moment I could display the currentBalance using {2} in message.properties. But I also need to inform user about lastBalance and deductedValue as well .. how to do that ?


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: custom error message for constraints

adwin grails
I also post this question on stackoverflow 


On Wed, Jun 2, 2010 at 10:51 PM, adwin grails <[hidden email]> wrote:

Hi,

I have domain with constraints like min value must greater than 0

I have no idea how to change the message if the constraints are not passed.

which file i need to edit to do that ?

I also need to display the values some properties as well .. like

"you cannot make any transaction because your balance is less than 100. Your current balance is ${currentBalance}. Your current balance is ${lastBalance} and amount that need to be deducted ${deductedValue} "  


note: my class Transaction has properties: lastBalance, deductedValue, currentBalance

the currentBalance has min(100) constraints

at the moment I could display the currentBalance using {2} in message.properties. But I also need to inform user about lastBalance and deductedValue as well .. how to do that ?



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: custom error message for constraints

John Stoneham
In reply to this post by adwin grails
On Wed, Jun 2, 2010 at 11:51 AM, adwin grails
<[hidden email]> wrote:
> at the moment I could display the currentBalance using {2} in
> message.properties. But I also need to inform user about lastBalance and
> deductedValue as well .. how to do that ?

I'd suggest using a custom validator in this case, and registering a
custom error on the Errors object with your additional args.

--
John Stoneham
[hidden email]

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...