myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Strittmatter, Stephan" <Stephan.Strittmat...@sybit.de>
Subject RE: selectItems alsway throw validation error
Date Tue, 27 Mar 2007 12:19:34 GMT
Hi Simon,

probably your Employee-Class is not serializable and do not implement equals?
If it is not implementing equals, every instance is different... 

Regards,

Stephan

-----Original Message-----
From: simon.s [mailto:simon.schroeder@gmx.de] 
Sent: Tuesday, March 27, 2007 2:08 PM
To: users@myfaces.apache.org
Subject: selectItems alsway throw validation error


Hi!

I already seached this forum but found no answer for my problem that I hope
is simple to fix.
I have a selectOneListBox that displays Employees that should be selected. I
wrote a converter but I always get a "Wert ist keine g├╝ltige Auswahl" -
means "value is invalid"

Here is my code:

<t:selectOneListbox id="employees" size="1"
value="#{newScheduleEntryForm.responsibility}">
    <t:selectItems value="#{peopleHandler.allEmployees}" var="thisItem"
itemLabel="#{thisItem.firstName} #{thisItem.lastName}"
itemValue="#{thisItem}" />
</t:selectOneListbox>


In newSheduleEntryForm
public EmployeeVO getResponsibility() {...}

public void setResponsibility(EmployeeVO responsibility) {...}

in peopleHandler
public List<EmployeeVO> getAllEmployees() {...}

the Converter
public EmployeeVO getAsObject(FacesContext context, UIComponent component,
String value) throws ConverterException {
if ( value == null) return null;
for ( EmployeeVO employee : ps.getAllEmployees())
{
	if ( employee.getId().toString().equals(value))
	{
		System.out.println("employee found: " + employee.getLastName()); //this is
put to console so the converter works!
		return employee;
	}
}
throw new ConverterException ("EmployeeConverter.getAsObject: There is no
EmployeeVO for Value " + value + ", type=" + value.getClass().toString());
}

public String getAsString(FacesContext context, UIComponent component,
Object value) throws ConverterException {
	if ( value == null) return null;
	if (value instanceof EmployeeVO)
        {
		EmployeeVO person = (EmployeeVO) value;
                return person.getId().toString();
        }
        throw new ConverterException ("EmployeeConverter.getAsString: This
is no EmployeeVO, value=" + value.toString() + ", type=" +
value.getClass().toString());
}
-- 
View this message in context: http://www.nabble.com/selectItems-alsway-throw-validation-error-tf3472646.html#a9691017
Sent from the MyFaces - Users mailing list archive at Nabble.com.



Mime
View raw message