File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation Error on SelectOneMenu

 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 135
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

this is how i declared the variable emptyString in the backingBean


Thanks for the reply!!

Rajeev.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic