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.

Reply via email to