Error happens when:
1) I filter my result set, and
2) the result set that comes back is empty
3) Then I re-filter my result set to display all records.
NOW -- if I get no records and populate a dummy bean, and then re-filter to show all records, then the first row in the table is fine, and the rest have the error.
Any ideas?
The answer to both of your questions is the SelectItem value.
Can you explain what you mean by filtering? What exactly is happening there? Code/JSP snippets will help.
The validation error is probably something along the lines of "Value is required" right? Do you have required="true" on the radio list tag? Irregardless, I have found that even if you have required="false" on the selectOneRadio it will still require a value. So if all your values are being stripped away by this filter, than depending on when your filter ran, JSF will think the user didn't enter anything and throw a validation error. I guess JSF radio lists just assume the user has to enter something.
CowKing
You gave me an idea.
What appears to be happening is a lifecycle issue. No values came back from the database. So we hit the data again, and before we can even populate that radio button with a value, it comes back with a validation (or conversion) error. Since there were no values the first time around.
So now I need to figure out a way around this.
By the way there are code snippets in this thread:
http://forum.java.sun.com/thread.jspa?threadID=5167026
Yes, if I had any money on it, I'd say it's a JSF lifecycle problem as well.
You'll have to explain the whole DB/no-values thing in detail to me. How do you identify you have no values and when in the JSF lifecycle (if you know)? When in the JSF lifecycle do you attempt to "hit" the database again?
I guess, just for clarity, what do you mean by "hit"?
Remember the request/response architecture that HTTP is built on. Once you've started your response from the server, you can't change it. Likewise, once the client has started their request, they can't change it.
CowKing
User requests page. Page renders with all records.
User can select from dropdown. Re-read database based on selection (i.e. select * from blah where field1=[user select]), and re-render page.
User may choose a criteria that, when we use to read the database, nothing is in the result set.
The funky thing with this JSF is that, when the user re-requests a page, the database is read TWICE. Something in the lifecycle is telling it to do that and I don't understand why. So it will read based on the old select statement, and then it will read again based on the new select statement.
How come it's reading twice?
Hmm... Nothing there looks particularly abnormal.
Is the DB call in a getter or setter? If so, JSF will naturally call the accessors several times throughout it's lifecycle. It is always wise to try and get ALL expensive operations (such as DB calls) out of the accessors when using JSF. This can be accomplished by using the bean constructor, valueChangeListeners, or action methods/actionListeners.
When the user selects the option from the drop down, do you make them click a button, or are you using a valueChangeListener?
Oh, and finally, what scope are the applicable managed-beans in?
CowKing