The following example associates the data tag attribute of the MapView with the dataSource property of
the dataBean bean:
<h:form id="form">
<jvmf:mapView id="mapId"
style="width:500px;height:300px"
data="#{dataBean.project}" />
</h:form>
In this case, JViews automatically stores the corresponding IlvManagerView instance according to the page identifier, but you must ensure that
the managed bean (dataBean) does
the same for the project property.
You can do this by converting it to a request bean that creates or retrieves the project
from the session, as follows:
// Holds the map project in the request bean
private String mapProject = null;
// The constructor tries to fetch the map project from the session,
// creating a new one if needed
public DataBean() {
// Try to retrieve the map project from the session
mapProject = (String)IlvFacesPageIdUtil.getSessionAttributeWithPageId("mapProjectId");
if (null == mapProject) {
// Map project not found in session, create a new one and then store it
mapProject = createMapProject();
IlvFacesPageIdUtil.setSessionAttributeWithPageId("mapProjectId", mapProject);
}
}
// The getter just returns the map project reference
public String getProject() {
return mapProject;
}
The code snippet shows a possible request bean implementation
where the getter method (getProject) uses the IlvFacesPageIdUtil API
to persist the map project object in the session object. IlvFacesPageIdUtil relies on the page identifier
to determine the page from which the request is submitted. Although
this example describes the data tag
attribute, the solution can be used for other tag attributes as well.