Baseline
... <h:panelGrid id="panelMyButton"> <a4j:commandButton value="myButton" action="#{myBean.execute()}" reRender="panelMyButton" ajaxSingle="true" /> </h:panelGrid> ...
@Name("myBean") @Scope(ScopeType.SESSION) @Synchronized(timeout=99999999) public class EditReclamationAction implements Serializable{ ... public void init(){ ... } public void execute(){ } ... }
<page view-id="myView.xhtml"> ... <action execute="#{myBean.init()}" /> </page>
Problem
Even if the action in <a4j:commandButton> is in ajax, the tag
Solution
Change the way to execute function and the scope type of the bean.
- In the bean, modify @Scope(ScopeType.SESSION) by @Scope(ScopeType.PAGE) to let possibility to initialize for each page loading
- In the bean, add “@Create” upper init(), that means for Seam run this function for each page loading
- Delete the tag <action> in pages.xml
like this :
... <h:panelGrid id="panelMyButton"> <a4j:commandButton value="myButton" action="#{myBean.execute()}" reRender="panelMyButton" ajaxSingle="true" /> </h:panelGrid> ...
@Name("myBean") @Scope(ScopeType.PAGE) @Synchronized(timeout=99999999) public class EditReclamationAction implements Serializable{ ... @Create public void init(){ ... } public void execute(){ } ... }
<page view-id="myView.xhtml"> ... </page>