Posted under JSF
Permalink
Tags Gotcha, JSF, Tip
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();
Leave a Reply
You must be logged in to post a comment.
