November 9th, 2010
6:54 pm
Fetching the old value in a JSF input validator

Posted under JSF
Tags , ,

In my case, I did this when checking string uniqueness in a table – if the value entered was unchanged, this would give a duplicate. Whilst I could in theory detect when I was comparing with the old value, this was hard in practice as I did not know which row I was on.

This trick is a good way of not bothering with validation if the field is unchanged. Note the need to cast the UIComponent passed in the event to a UIInput in order to expose the getValue method. Sample code is as follows :-

String oldValue = ((UIInput)component).getValue().toString().trim();

No Comments »

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.