I guess your talking about the Oracle Forms session (and its associated database session). With it's default behavior OraFormsFaces will try to start only a single applet instance for the entire web application session. The first page in a session that uses OraFormsFaces will cause the applet to load. When the user navigates away from the page that applet is suspended into the legacy lifecycle cache of the browser. While it is there it keeps running (technically) but it won't be visible in any way. This does mean that things like the periodic heartbeat to the forms server keeps running to keep the session alive.
When the user navigates to a page that uses OraFormsFaces the browser will resume the old applet from the cache. The applet will resume just as it was when it was suspended. Since it is likely the user is now on a different page and wants to see a different form, OraFormsFaces will close all open forms on a resume and start a fresh copy of the form required for the current page.
With this in mind a web browser session should only have a single Forms applet instance and thus a single session at the Forms server with a single session at the database server. Any forms globals or database package variables are part of the session and will survive this suspend/resume cycle.
There's a number of things to keep in mind:
- Mozilla Firefox 3.5 and newer will destroy the page a user is leaving in parallel with creating the page the user is navigating to. This can cause the new page to request an applet before the old page has released/suspended it. If this happens a new applet instance will be created. In the end, this could mean a single web browser session ends up with multiple forms applets of which maximum one is currently showing. There is no way to force which individual applet instance is used on a next page just as there is no way to disable this parallel destroy/create. This means you cannot rely on forms globals, database package variables or other types of state to survive across pages with Firefox.
- With the previous firefox remark in mind, it is always best to not rely on session state at the forms server or database. The session at the JSF application server should be leading as this is the primary session for the user. You could create a session scoped bean to contain session information and pass its values to forms globals with the <off:Formparameter> component. Relying on database package variables as a means of state is getting less reliable in modern applications as well. The JSF web application (as many other web style apps) will use a pool of database sessions where each page request could theoretically be handled by a different database connection. The container will try to give you the same session for each request, but this is not guaranteed. Hence you cannot rely on database session state there either.
- You can alter the default OraFormsFaces behavior if you need to. You can implement a PL/SQL function (shouldFormClose) that decides whether the current form should be closed when the applet resumes on a page. By default this will return true, but you can re-implement it with custom logic. The function gets all attributes of the JSF off:form component and parameters for both the previous and current page. This means you can decide not to close/restart forms unless a different form or different customer was selected (for example)
- Currently there is no easy (documented) way to have different JSPX pages use a different applet instance by definition. This is something that is in the current development version and should be included in version 3.1
- You could opt to set the legacy_lifecycle parameter to false disabling the entire mechanism. That would destroy the applet each time a user navigates away or reloads the page. Each page would start a fresh new applet instance which in most cases significantly impacts performance.