views:

175

answers:

2

INITIAL POSITION:

We are using SEAM together with RICHFACES.

We've got the following page configuration with an action (called actionBean.doBefore), that should be executed once on page load:

<page>
  <action  execute="#{actionBean.doBefore}"/>
  <navigation from-action="#{actionBean.doAfter}">
    <redirect view-id="/view/component/test.xhtml" />
  </navigation>
</page>

PROBLEM

The action is even executed when we validate a field per ajax:

<h:inputText value="#{formBean.price}" id="price" required="true">
  <a4j:support event="onblur" reRender="price" ajaxSingle="true" bypassUpdates="true" />
</h:inputText>

or use a suggestion box (even when you type):

<rich:suggestionbox id="suggestionBoxId" for="city" suggestionAction="#{suggest.autocomplete}" var="result" minChars="3" nothingLabel="No capitals found" ajaxSingle="true" bypassUpdates="true" selfRendered="true" >
  <h:column>
    <h:outputText value="#{result.cityName}" />
  </h:column>
</rich:suggestionbox>

Thanks in advance Raffi

+1  A: 

As far as I know you can't. The action will always be called.

Instead of using a page action why don't you scope your Backing Bean to PAGE or CONVERSATION and then perform the action from a method annotated with @Create? This will give you the same effect as the page action but will only be called the first time that the Bean is instantiated.

Damo
A: 

thanks a lot. would be another approach. the following attribute on the action tag seems to solve my problem. hopefully with no side effects:

<action  execute="#{actionBean.doBefore}" on-postback="false"/>
rschmid