Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Validation Error on SelectOneMenu

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

this is how i declared the variable emptyString in the backingBean


Thanks for the reply!!

Rajeev.
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic