Monday, 15 July 2013

java - How to change the default "Validation Error: Value is not valid" message? -



java - How to change the default "Validation Error: Value is not valid" message? -

below 4 related posts find on stack overflow:

validation error: value not valid validation error value not valid jsf : validation error value not valid selectonemenu jsf enum 'validation error: value not valid'

in these posts, posters didn't know why had error message. in case, know why have error, , alter default "validation error: value not valid" message let's "this message". how accomplish this?

ps1: tried requiredmessage, validatormessage , convertermessage attributes, none of them called in special case.

ps2: i'm using richfaces 4.1.0, drop-down list i'm using rich:select one.

scenario:

i have 2 entities, illustration employers , employees. i create employee employee1. i want create employer employer1, , link employee1 via drop-down list. before submitting employer creation form, delete employee1 database. then, submit employer creation form: said message appears next drop-down list, since employee1 isn't available anymore.

this behavior 1 expected, alter default message one, more user-friendly.

supply custom converter , throw converter exception in getasobject().

basically,

@override public object getasobject(facescontext context, uicomponent component, string submittedvalue) { if (submittedvalue == null || submittedvalue.isempty()) { homecoming null; } employee employee = findemployeeindatabase(submittedvalue); if (employee == null) { throw new converterexception("sorry, unknown employee."); } else { homecoming employee; } }

note enables utilize convertermessage.

java jsf validation message default-value

No comments:

Post a Comment