ModalPanel backing bean instanciated too early -> no content
shino May 6, 2009 4:50 AMHi,
I'm using a modalpanel to display and edit data, which the user selected by double-clicking on a datatable row.
My problem is, that upon doubleClick, the modalpanels request scoped backing bean is created, before the selected data is written into the corresponding property of my session scoped managed bean. The result is, that the content of my modalpanel always lacks behind one request, on the first double-click it is empty, on the second one it shows the data that should have been shown before etc.
Here is the relevant code of dataTable:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <f:loadBundle basename="messages" var="msgs"/> <rich:panel header="#{msgs.addressOverviewTitle}" style="height : auto; width : auto;"> <rich:spacer height="6"></rich:spacer> <h:form> <rich:dataTable value="#{addressesModel.addressesTableData}" sortMode="single" id="addressesTable" var="address" rowKeyVar="currentAddressIndex" columns="9" rows="#{preferencesModel.maxTableEntries}" headerClass="addressesTableHeader" rowClasses="oddRow,evenRow"> <a4j:support id="editAddressSupport" event="onRowDblClick" action="#{addressesModel.selectCurrentAddress}" oncomplete="#{rich:component('editAddressMP')}.show();" reRender="editAddressForm"/>
(addressesModel is a session scoped bean.. perhaps I will create a seperate controller class for things like keeping a selected address, so responsibilities are clearly seperated, but thats a bit off topic ;-))
I don't know how to fix this without changing my logic.. though it seems "right" to me to first select the dataobject and then create the backing bean which populates the modalpanel using the data from the session bean. Can anyone point me to the right direction here?
best regards
Chris
P.S.:
One thing I also noticed is that the backing bean for the modal-panel is first instanciated when the whole page loads, in other words: before the modal-panels visibility state changes. Even though this makes sense because the ui:include command isn't executed conditionaly and is processed together with the rest of the page, it doesn't seem desirable to have the bean instanciated when it might not be needed at all. Is there something I'm missing here, or is this just the way modalpanels work?