-
1. Re: dataTable with method execution per row
paradigmza Jul 7, 2006 3:28 AM (in response to trouby)Hey,
I am not quite sure why
note: the 'status' cannot be just a property of the 'user' entity since the method requires DB access(and more) and must reside in an EJB entity....
and this is the way I would do itpublic class User { private Integer userid; private String status; ...getters and setters... }
@Stateful() @Name("somename") @Scope(ScopeType.SESSION) //or whatever public class UserBean implements UserInterface { @DataModel List<User> userList; @DataModelSelection User selectedUser; @PersistenceContext EntityManager em; public String doSearch() { updateUserList(); return "userlistpage"; } private void updateUserList() { Query query = em.createNamedQuery(....) result = ...connect to databases... ...and more ;-) ... userList = result }
-
2. Re: dataTable with method execution per row
pmuir Jul 7, 2006 4:31 AM (in response to trouby)You could always preprocess the list.
Mark the status field in the user Entity @Transient (so that it isn't persisted by the container). In updateUserList() iterate over the list created by the database query setting status as you go (here you could interogate other entites, SOAP, whatever). -
3. Re: dataTable with method execution per row
cptnkirk Jul 7, 2006 11:34 AM (in response to trouby)You may also be able to write a JSF EL function. However I think I Pete's method of just getting status along with the original data better.
-
4. Re: dataTable with method execution per row
supernovasoftware.com Jul 7, 2006 12:24 PM (in response to trouby)I do preprocessing of lists with @Transient. It works quite well. I also use maps that I add extra objects to to hande the case where some of then are not persisted and I add an empty one under a different key in the map if there is none found.
-
5. Re: dataTable with method execution per row
gavin.king Jul 10, 2006 12:37 PM (in response to trouby)"trouby" wrote:
but since JSF/Seam limitations(or am I wrong?), I can't pass parameters to methods and execute them
This is a limitation of JSTL-EL. In our experimental JSF fork, Stan has actually implemented method parameter support, but note that we have no current plans to productize this work. -
6. Re: dataTable with method execution per row
trouby Jul 10, 2006 2:22 PM (in response to trouby)Cool, but thanks,
I'll stick with the @Transient pre-loaded data options for now... -
7. Re: dataTable with method execution per row
bfo81 Jul 11, 2006 5:58 PM (in response to trouby)I'm not sure if I understood your problem. But this reminds me of a list of entities in which I wanted to show the amount of relations to other entities (just like e.g. users and his posts in this forum). So I put the following into the user entity:
@Formula("(select count(*) from Post p where p.user_id = id)") private int postcount; //+ getter + setter
The query for the postcount var is being executed on the fly for every user in this example. Maybe you can adapt this proceeding for your purposes.