-
1. Re: Conceptual problem: Reusable lists?
gavin.king May 24, 2006 4:14 PM (in response to eekboom)You can always do it in the standard JSF way, and create a ListDataModel that you keep inside your component.
-
2. Re: Conceptual problem: Reusable lists?
pmuir May 24, 2006 4:47 PM (in response to eekboom)Surely something like
@Stateless @Name("employeeManager") public class EmployeeManagerBean implements EmployeeManager { @DataModel(scope=PAGE) private List<Employee> employees; @In(required=false) private Boolean internal; @In(required=false) private Branch status; ... @Factory("employees") public void employeeFactory() { employees = em.createQuery(...).getResultList(); } }
should work. The bean is stateless so the list will be rebuilt each time the employees variable is accessed per page but the datamodel is outjected to the PAGE scope so that clickable lists work. You shouldn't need to null the employees list manually here I think but I may be wrong as I haven't tried it yet myself. -
3. Re: Conceptual problem: Reusable lists?
eekboom May 26, 2006 12:09 PM (in response to eekboom)Thanks for the answers. I have to think a little more about wether page or maybe conversation scope would work in my case.
Gavin, you're proposal makes sense. However it would save me some work if the code that wraps a collection in a ListDataModel would be made public.
Why should I duplicate code that seam already contains?
Ok to file a Jira issue for that? -
4. Re: Conceptual problem: Reusable lists?
gavin.king May 26, 2006 12:30 PM (in response to eekboom)huh? the code is: new ListDataModel(myList)
-
5. Re: Conceptual problem: Reusable lists?
eekboom May 26, 2006 1:40 PM (in response to eekboom)*ashamed*
See, I only started with JSF for about a couple of hours when I realized that I am missing the funcionality that Seam offers.
Now you made the clickable list tutorial sound so nice and easy that I thought it would be much more complicated with pure JSF.
Should have read some more.
Now your original suggestion makes yet more sense - I see that the only code I need is a getter that lazily initializes a field with a single constructor call.
Sorry for my stupid question. -
6. Re: Conceptual problem: Reusable lists?
gavin.king May 26, 2006 3:20 PM (in response to eekboom)No problem ;-)