sample:
I have 2 tables, department and employees (these 2 table is link via the department_id foreign key in employees). and obviously, department has a one-to-many relationship with the employees table.
I need to create a form that has a subset of data from both tables.
These are fields in the web form.
- family/surname (from employees table)
- first name (from employees table)
- employment start date (from employees table)
- department (drop-down list of the various departments with department_id as the value return and obviously from the departments table).
I’m wondering if creating a new class for these 4 fields is “best practice”? Thanks! 🙂
If you are just returning one of each, you can simply add them to the Model. If you are returning a bunch of “rows” of these things, then I would say it makes more sense to wrap the values in a Bean and pass back a collection of instances of that bean. It makes it easier to look through them on the view-side.