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"/> </rule> </navigation> </page>