Communication between JSF and beans

Hi,

I am a JSF starter and I have a "best practice" question regarding lookups.

Assume a simple db design that has two tables, EMPLOYEE(EMP_ID, EMP_DEPTID) and DEPARTMENT (DEPT_ID, DEPT_NAME).

At the bean level we have two classes, Employee and Department.

class Employee {

int id;

Department department;

}

class Department {

int id;

String name;

}

At the JSF level we need a SelectOneMenu in order to pick the department for an employee. If we had a "deptid" in Employe, then this should be the "value" property of the select. But we have a whole object so what the value should be? How do you handle such a situation?

TIA

Denis

[724 byte] By [denispyra] at [2007-11-27 6:15:13]
# 1
True, you have a whole department object. But department has an id, right, so can't you still just take the department object's id?
transcendencea at 2007-7-12 17:25:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hm, not sure.I think this way I set the id of the department so I guess I change the department object. What I want is to lookup for the department that has the new id and set it as employee's department.Thanks for your responseDenis
denispyra at 2007-7-12 17:25:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...