permaculture playing cards*
The moose likes JSF and the fly likes Validation Error: Value is not valid Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Validation Error: Value is not valid " Watch "Validation Error: Value is not valid " New topic
Author

Validation Error: Value is not valid

A Saari
Greenhorn

Joined: Mar 31, 2006
Posts: 26
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

Joined: Feb 18, 2003
Posts: 166
Does your myObject class extend the SelectItem class. I believe this is a must.


Jeremy Wilson
A Saari
Greenhorn

Joined: Mar 31, 2006
Posts: 26
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

Joined: Mar 31, 2006
Posts: 26
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

Joined: Jan 04, 2008
Posts: 3
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".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation Error: Value is not valid