selectOneListBox and why validation is not working on it

Hi,

I have a selectOneBox and my first item on the list is a default or a "Select One" text, but adding this, my validation doesn't work. I need this selectOneBox to be required and my error message is not coming up when I submit it with the "Select One" text as the choice.

Anyone know how to fix this?

thank you.

[340 byte] By [KY8a] at [2007-11-26 18:41:44]
# 1
Supply a null value to the first item and implement a custom NullValidator which checks whether the selected item is null or not and accordingly throw a ValidationException.
BalusCa at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Do you have a custom validator or are you relying only on the required flag? If so, the required message only comes up, if the SelectOne is empty (eg. "")

So, if you insert the selectItem-Tag like this:

<selectOneMenu...>

<f:selectItem itemLabel="" itemValue=""/>

<f:selectItems...>

</selectOneMenu>

the required message should come up if you doesn't select an entry.

UlrichCecha at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
How would I do that in RAD using design view and not coding?thank you
KY8a at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Which RAD-Tool are you using? In StudioCreator for example it's easy to change to the JSP-View and add the Tag manually.
UlrichCecha at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

This is what I have in my code:

<h:selectOneListbox styleClass="selectOneListbox"

id="application" size="1" value="#{pc_Form.name.application}" required="true">

<f:selectItem itemLabel="Select One" itemValue="" />

<f:selectItems

value="#{selectList.appList}">

</f:selectItems>

</h:selectOneListbox><h:message for="application" id="ApplicationError" styleClass="messageError">

But submitting still won't give me an error, even with the first choice selected.

?

Message was edited by:

KY8

KY8a at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
RAD7
KY8a at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Hey, it works if I put <f:selectItem itemLabel="" itemValue="" />is there a way to label it "Select One" and get the error message is that is the choice?thank you for all your help
KY8a at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Sorry, but I don' know RAD7.But change your code so that "Select One" is replaced bei "" (empty string) or if you are fixed on the string, implement a custom validator (like BalusC mentioned before)...
UlrichCecha at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Thank you UlrichCech. It works!
KY8a at 2007-7-9 6:15:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...