Modal Panel and EJB load
ibstmt Feb 14, 2011 3:22 PMI have a problem where the main method of my EJB gets fired whenever I call a Modal Panel. Here are the snippets of my application:
(pages.xml)
<page view-id="/main.xhtml" login-required="true" action="#{myEJB.load}">
<begin-conversation join="true"/>
<param name="callerUrl" required="false" />
<param name="callerSupportsMultipleResult" required="false" />
<navigation>
<rule if-outcome="home">
<redirect view-id="/main.xhtml"/>
</rule>
<rule if-outcome="back">
<redirect view-id="/main.xhtml"/>
</rule>
</navigation>
</page>
(myEJB.java)
@Stateful
@Name("myEJB")
@Scope(ScopeType.CONVERSATION)
public class MyEJB {
....
public void load() {
(bunch of initialization code)
}
(main.xhtml)
...
<rich:menuItem submitMode="none" value="Edit">
<a4j:support event="onclick" immediate="true"
action="#{anotherEJB.edit}"
reRender="editForm"
oncomplete="#{rich:component('editModal')}.show()"/>
</rich:menuItem>
...
<rich:modalPanel id="editModal" autosized="true">
<f:facet name="header">
<h:outputText value="Edit" style="padding-right:15px;" />
</f:facet>
<ui:include src="editForm.xhtml" />
</rich:modalPanel>
(editForm.xhtml)
<rich:toolBar>
<rich:menuItem submitMode="none" value="Save" icon="/images/save.png">
<a4j:support event="onclick" immediate="true"
reRender="mainPanel"
action="#{anotherEJB.save}"
oncomplete="#{rich:component('editModal')}.hide()" />
</rich:menuItem>
</rich:toolBar>
<h:form>
<h:panelGrid id="editForm">
...
</h:panelGrid>
</h:form>
My problem is that every time I choose the Edit menu option on main.xhtml, the load() method in myEJB gets fired when the modal appears (before I close the modal, not after). The modal panel comes up correctly, no problems, but I don't need the load() method to fire every time. I can't remove the action reference in pages.xml, though, because that's needed for other functionality.