3 Replies Latest reply on May 16, 2009 10:01 AM by netkiss.li

    Ejb session bean not be called by a:support

    netkiss.li
      jboss-4.2.3.GA / jboss-seam-2.1.2.CR1 / jdk1.5.0_16

      Code:
      @Local
      public interface ViewByLibFace {
          void showNextPhoto();
      }

      @Name("viewByLib")
      @Stateful
      @Scope(ScopeType.SESSION)
      public class ViewByLibAction implements ViewByLibFace {
        public void showNextPhoto() {
             // todo:
        }
      }

      <!-- xhtml file -->
      <h:outputLink
      value="javascript:;"> show next
      <a:support
          event="onclick"
          eventsQueue="photoQueue"
          ignoreDupResponces="true"
          ajaxSingle="true"
          bypassUpdates="true"
          action="#{viewByLib.showNextPhoto}" />
      </a:support>
      </h:outputLink>

      Question:
      I click the show next link, it works.

      But I really don't like to set the action to session scope.
      I have no so many memory...

      when I remove the @Scope(ScopeType.SESSION) from the Stateful action. The method showNextPhoto() didn't be called by click the link. And any exception wasn't found in console and page.

      Can you tell me why, and how should I do to use the ajax4jsf with seam ejb session?


        • 1. Re: Ejb session bean not be called by a:support
          netkiss.li

          a4j:keepAlive


          extends the live cycle for request scope beans. In general, each Ajax request works inside the own request scope. Therefore, the state of the component tree rendered based on the variable from one request scope does not correspond to the state of the same tree processed during the next Ajax request. This causes one of the most widespread problem when the form elements (buttons or fields) can't be correctly proceeded with Ajax if the 'rendered' attribute is mapped to the request scoped variable


          Using the session scope variables solves the above mentioned problem. However, using a session scope might be inappropriate from the architectural point of view. a4j:keepAlive allows to reuse the same value for a request scope bean between several Ajax requests.


          beanName attribute references to a request scope bean name you'd like to re-use during the Ajax requests.


          http://livedemo.exadel.com/richfaces-demo/richfaces/keepAlive.jsf

          • 2. Re: Ejb session bean not be called by a:support
            netkiss.li

            Impertinence sample will misadvise an user, so I think Seam dev team should update your booking example.

            • 3. Re: Ejb session bean not be called by a:support
              netkiss.li

              But the stateful bean can't be bind to request scope.
              Anyone can give me a suggestion?