I have a JSF-App with two @ViewAccessScoped
Beans and two Pages/Views, one Bean for a Search, on Bean for details. The details Bean references the @ViewAccessScoped so the data available when I go back to the Search. No other CDI-References. The WindowRenderMode is ClientWindowRenderMode.CLIENTWINDOW
, no further configuration.
This works quite well so far. The Beans get un-scoped if i go to another page or logout. One Problem I Experienced: When I open my details page in a new Browser tab, two new Beans are created, which is the expected Behavior. But when i close the tab, the Beans are still there. I guess the Server doesn't get notified when a tab get's closed.
No, as it's not possible to catch a "tab close" event in JS. See: javascript detect browser close tab/close browser
It was available in CODI but it was not migrated to DeltaSpike. See: https://issues.apache.org/jira/browse/DELTASPIKE-437
You can do it via the WindowContext API:
@Inject private org.apache.deltaspike.core.spi.scope.window.WindowContext windowContext;
public void closeIt() {
windowContext.closeWindow("myWindowId");
}