9.5. Using <s:link> and <s:button>

JSF command links always perform a form submission with JavaScript, which causes problems with the web browser's 'open in new window' or 'open in new tab' feature. To get this functionality in plain JSF use <h:outputLink>, but there are two major limitations to this method:
  • JSF provides no way to attach an action listener to <h:outputLink>
  • JSF does not propagate the selected row of a DataModel, as there is no actual form submission.
To solve the first problem, Seam implements the notion of a page action. You can work around the second problem by passing a request parameter and requerying for the selected object on the server-side; in some cases like the Seam blog example application, this is the best approach. As it is RESTful and does not require a server-side state, bookmarking is supported. In other cases, where bookmarking is not required, @DataModel and @DataModelSelection are transparent and convenient.
To replace this missing functionality, and to simplify conversation propagation further, Seam provides the <s:link> JSF tag.
The link can specify only the JSF ID:
<s:link view="/login.xhtml" value="Login"/>
It can also specify an action method, in which case the action outcome determines the page that results:
<s:link action="#{login.logout}" value="Logout"/>
If both a JSF view ID and an action method are specified, the view will be used unless the action method returns a non-null outcome:
<s:link view="/loggedOut.xhtml"  action="#{login.logout}" value="Logout"/>
The link automatically propagates the selected row of a DataModel inside <h:dataTable>:
<s:link view="/hotel.xhtml" action="#{hotelSearch.selectHotel}" 
   value="#{hotel.name}"/>
You can leave the scope of an existing conversation:
<s:link view="/main.xhtml" propagation="none"/>
You can begin, end, or nest conversations:
<s:link action="#{issueEditor.viewComment}" propagation="nest"/>
Finally, use <s:button> to 'link' rendered as a button:
<s:button action="#{login.logout}" value="Logout"/>