I recently ran into a problem where a Visualforce page was throwing a cryptic error message related to a custom picklist (apex:selectList). The complete error was something like:
j_id0:frmSelectProductsServicesw:filterSection:j_id10:j_id15:selectedPF:Validation Error: Value is not valid
After some digging and research here in the forums, testing and a call to Tech Support it seemed the cause and solution for similar problems didn't quite apply. I eventually found the solution (in my case) and wanted to share it in hopes that it would help others.
The cause was due to a conflict between the underlying stored data in SFDC and how certain controls behave when rendered to HTML. In this case, there was a double space embedded in the underlying data between the Z and I in the value Product.Family field (eg. ‘S&U Z Internal’).
- For Visualforce controls (ie. apex.outputField, apex.outputText, apex:selectList) and modes (ie. edit and view), every control ultimately must renders as HTML. Typical HTML rendering behavior suppresses any extra spaces within text. That is why it is common practice to use the   to chain multiple spaces together.
- In this case, the underlying stored data in the Product.Family field included a double space:
‘S&U Z Internal’
however when it was rendered to the screen, the HTML took control and used only a single space:
‘S&U Z Internal’
- Once the user clicked the submit button to begin the search, the picklist in this case tried to cross-reference the selected value with the actual data that was bound to the control and found no match, thus the cryptic error that was returned - “selectedPF:Validation Error: Value is not valid”.
‘S&U Z Internal’ != ‘S&U Z Internal’
Funny thing is, when the underlying data is rendered in a input textbox (ie. apex.inputText), the double space is displayed. Once I removed the double space from the underlying data, the error was fixed.
Hopefully this solution helps.
Thanks to Sreenivas Voore in Premiere Tech Support.