This is with MyFaces CODI JSF-Module v1.0.1 for JSF 2.0
I have JSF page that uses a @ViewAccessScoped backing bean and it does pretty much what I want it to, except it doesn't go away when I am done with it. The page is invoked from another page like this:
<h:link outcome="/editLocation" target="_blank"
value="Edit Location: #{maintLocation.selected.id}"
disabled="#{!maintLocation.rowSelected}">
<f:param name="locationID" value="#{maintLocation.selected.id}" />
<f:param name="closeOnUpdate" value="true" />
</h:link>
The user experience is that the editLocation page pops up in a new window or new tab, the user edits it, and on completion it calls window.close() if the closeOnUpdate parameter is set true.
That all works. But if the user edits another location the ViewAccessScoped bean is still there so it doesn't get re-instantiated. As such it never sees the parameters and simply comes up with the state that it is in with the prior record.
By manually erasing the windowid parameter in the browser URL window I can get a new backing bean. Is there a way to remove this from the h:link component?
Alternatively, is there a way for the bean to remove itself from the scope that it is in once it hits the complete button?
I found the answer on the CODI Wiki page. Although I am not implicitly using CODI Conversations, the @ViewAccessScoped implementation seems to be layered on top of it. So I could do:
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
...
@Inject private Conversation conversation;
...
conversation.close(); // when I have committed to close the window.