wood burning stoves 2.0*
The moose likes JSF and the fly likes Validation Error on SelectOneMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Validation Error on SelectOneMenu" Watch "Validation Error on SelectOneMenu" New topic
Author

Validation Error on SelectOneMenu

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
hi,

Im getting validtion error on SelectOneMenu while submiting the page
this is my code



im developing a prototype, i was getting the error message only in selectonemenu. I tried setting the value with " value="#{sessionScope.selectOneValue}" but it is still throwing error.

this is the error message

com.sun.faces.context.FacesContextImpl addMessage Adding Message[sourceId=entryform:mainTabView:submitPage:uwReview,summary=Validation Error: Value is not valid)


Has anyone faced this issue ? Any help or suggestion on this is appretiated !

Thanks,
Rajeev
gopal kishan
Ranch Hand

Joined: Feb 23, 2005
Posts: 99
Hi ,

instead of giving the list values in jsp , you can create a list in your backing bean and you can call that list in your jsf.

it will solve your problem.

for eg:

in backing bean:

variable:
private String eventType;
private static SelectItem[] allEventTypes = new SelectItem[] {
new SelectItem("Select All"),
new SelectItem("first"),
new SelectItem("second")
};

method:
public SelectItem[] getAllEventTypes(){
return allEventTypes;
}

public static void setAllEventTypes(SelectItem[] allEventTypes) {
BackingbeanName.allEventTypes = allEventTypes;
}

getter and setter for eventType also.
in JSP:
<h:selectOneMenu id ="eventType" value="#{formName.eventType}" required="true">
f:selectItems value="#{formName.allEventTypes}"/>
</h:selectOneMenu>


hope this will help.

Gopal
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Gopal, thanks for the reply and code. im still getting the same error message. I hav made some changes in the code you send me, because i dont want SelectItem[] to be declared static

i will copy my jsp and backing bean , please have a look at it and let me know if i am doing anything wrong.



the error message im getting is
com.sun.faces.context.FacesContextImpl addMessage Adding Message[sourceId=newRegularApp trixMainTabView:multipleBorrowerPage:borrowerTabViewId:borrowerPage:myselect,summary=Validation Error: Value is required.)

Thanks,
Rajeev
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
Can you post the code for pc_Borrower.emptyString? Is it a proper getter/setter property or you always return empty string for the property?

Just wonder if empty string is always returned, then it wouldn't pass the required=true validation check.


SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
hi,

this is how i declared the variable emptyString in the backingBean


Thanks for the reply!!

Rajeev.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Validation Error on SelectOneMenu
 
Similar Threads
CSS for individual selectItem tag
JSF prevents custom validator from getting control
i am facing some problem with <h:selectOneMenu>
Best way to create a combo-box (editable selectBox)?
Validation Error: Value is not valid.