문제

I can't inject a ConversationScoped bean into a ViewScoped bean, because the ConversationScoped bean could be shorter lived than the ViewScoped one, or vice versa, depending on whether or not the ConversationScoped bean is long-lived.

To get over this limitation, I tried using an f:event to perform the injection as a preRenderView listener:

<f:metadata>
   <f:event type="preRenderView" listener="#{taskController.initializeTask(workPackageConversation.workPackage)}" />
</f:metadata>

This howver is not working, neither the listener initializeTask, nor the getter getWorkPackage are being called.

I realize I can lookup one managed bean from another, using the FacesContext, but I am curious why this isn't working. Is it because the f:event listener isn't called when I navigate to a view from another view? ie. without a redirect or direct page view?

I also tried the s:viewAction tag from Seam 3 Faces, to no avail. It does not get called either.

Thanks in advance.

도움이 되었습니까?

해결책

I would think the lifetime issues would not come into play since you've always got a proxy to the normal-scoped bean anyway. You either dereference the conversation-scoped bean while the conversation is active, or it's not active -- but you'll always get the right conversation.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top