Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation Error: Value is not valid

 
A Saari
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all

i'm getting the above error on a submit using a h:selectManyListbox

i build my list of SelectItems(myObject,myLabel) where myObject class overrides the equals() method:

public boolean equals( Object o )
{
// do some stuff
return true;
}

but the equals() method is never called - anyone know why?

i also implemented javax.faces.validator.Validator;
and the method

public void validate(FacesContext facesContext,
UIComponent uiComponent,
Object o) throws ValidatorException {
}

which does get called. i just return without throwing a
ValidatorException

Can anyone tell me why the 'Validation Error: Value is not valid' is being thrown - and from where?

Thanks,
Amy
 
Jeremy Wilson
Ranch Hand
Posts: 166
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your myObject class extend the SelectItem class. I believe this is a must.
 
A Saari
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. So I added that in

public class ProjectsList extends javax.faces.model.SelectItem {

the equals method still is not called and i get the

same validation error - i appreciate the thought though ...

Amy
 
A Saari
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solution

The class I was sending to the new SelectItem(myClass,myLabel) had an Integer as the projectID. I changed that to a String. Tossed out my custom converter, tossed out my validator. Made sure myClass extends SelectItem

public class ProjectsListItem extends javax.faces.model.SelectItem implements java.io.Serializable {

then I added <managed-property tag to the managed bean

<managed-bean>
<managed-bean-name>loginModel</managed-bean-name>
<managed-bean-class>xxxxxxxx.LoginModel</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>projectsList</managed-property>
</managed-bean>

and it works. No validation error. I think the response was sending a String and decode() for the component was trying to find/convert its value and I was getting a validation error because my list of SelectItems (projectsList) contained a class that had an Integer projectID rather than a String.

Amy
 
zel branco
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this error because I was adding "mixed data type" in to key
value of "SelectItem"..
ie I was adding "" - String - and adding the rest of the values as "Long".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic