conditonal validation
Hi,
I need a solution to solve a problem with showing an error image next to a textbox if it's empty.
Right now, when a button is clicked (action, not actionListener, immediate false), I go through the entire tree, check each field, see if the value is empty, if it is, I added to the error message queue. The problem is, if one of the textbox is empty, I need to show an error image next to it.
I thought about checking if the corresponding bean value of the textbox is empty or not, but the problem is when the first time it enters the page, the error image would show up.
How do you solve this problem?
[641 byte] By [
lmxua] at [2007-10-2 9:48:55]

okay, I tried this
<h:graphicImage url="/images/error.gif" alt="required" rendered="#{empty myBean.residentState} /">
by default, getResdientState returns an empty string "" . if no value is set. but the above image never shows up as if there is non empty value there. help please.
Really appreicate it.
lmxua at 2007-7-16 23:54:11 >

okay, this is what I use now
<h:graphicImage url="/images/error.gif" alt="required" rendered="#{myBean.residentState eq '' } /">
if there is no value, the error image will show, if there is a value, the error image won't show.
The problem is, upon the first time it enters the page, the inital value is empty ''. so the image will automatically shows up. No good. The first time, it show not show. Only when my action buttion is clicked, should it check.
suggestions will be greatly appreicated.
lmxua at 2007-7-16 23:54:11 >

okay problem solved. if i change the "no state chosen" value to "-1" and backend default to empty string '', then do
<h:graphicImage url="/images/error.gif" alt="required" rendered="#{myBean.residentState eq '-1' } /">
it'll work. kinda sucks i have to keep track of different default values eveyrwhere, but it works. Same princiapl applis to any other fields.
thanks.
lmxua at 2007-7-16 23:54:11 >
