0 Replies Latest reply on Feb 8, 2008 6:32 PM by Alan Feng

    Using @Begin action method together with view

    Alan Feng Novice

      After many tries and errors, I feel method annotated with @Begin is very confusing to use.

      First of all, JavaDoc of @Begin says:
      - If method is void type, a new conversation always starts, even a "join" is specified.
      - If method is not void type, @Begin only triggers if the method returns a Not Null value and no exception.

      Sounds okay so far. But when I use it with a view specified, such as in
      <s:link view="/myView.seam" action="#{myComponent.beginAnnotatedAction()}"/>
      (or in the pages.xml file with similar code)
      The seam doc says:
      If action returns a not null value, it will be used to determine the actual view to render. The view specified is only used when action returns Null or of void type.

      Put the above two together, I got a dilemma. In order to be able to join a conversation with the annotated action method, the action needs to return a not null value, which means I need to hard code my navigation into the action method. Further more, since it is forced to return a non-null value to start the conversation, it won't seem to make sense to use it with a view in the pages.xml file:

       <page view-id="/myView.xhtml" action="#{myComp.annotatedAction()}">
       <navigation from-action="#{myComp.annotatedAction()}">
       <rule if-outcome="success">
       <redirect view-id="/myView.xhtml"/>

      Will this lead to a infinite loop?

      In summary, I am not sure how to correctly use the @Begin annotated action with view specification in <s:link> and in the pages.xml file. My common scenario is when a view is loaded, a conversation usually needs to begin if non exists, or join the existing one. Meanwhile, some data needs to be fetched from the DB so the view can be rendered. And and @Begin annotated action with a view specified has caused lots of problems so far due to the above mentioned reasons.

      Any comments are welcomed. Thanks.