[jboss-user] [JBoss Seam] - Re: Multiple beans outjecting same variable - how to control

ASavitsky do-not-reply at jboss.com
Tue Aug 21 11:20:34 EDT 2007


"vincent.latombe" wrote : AFAIK, outjection is done after each call of each method of a component.
Yes, if there's a method call - but what if there isn't one?

My use case is pretty simple, actually: there's an entity X, with an User attribute, so that each user can see their own Xs, while an admin can see all of them (optionally filtetred by user). Thus, there's an EntityQuery set up ("FROM X x") with restrictions in the form of "x.user = #{selectedUser}", where selectedUser is outjected. Admin screen either outjects null (default on page load) or the user that list should be filtered on (via method call in admin screen controller). User screen, OTOH, is to automatically outject the current logged in user as selectedUser. To accomplish this, the controller bean for user screen declares @In @Out ("selectedUser") User principal; (principal is the current logged in user, outjected into session on login).

The only problem is, there's no way to control which of the controller beans would outject the value first (on first page load, for instance). The hacker way to solve this is to introduce a no-op method in each of the controllers, that would execute on page load and do all the outjection, like that: <page view-id="/attestation/accounts.xhtml"
  | 		action="#{accountController.noOp}" />, but of course this is just a hack...

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4076361#4076361

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4076361



More information about the jboss-user mailing list