此内容没有您所选择的语言版本。

8.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. If you require this functionality in plain JSF, you need to use an <h:outputLink>, but there are two major limitations to this method:
  • JSF provides no way to attach an action listener to an <h:outputLink>, and
  • JSF does not propagate the selected row of a DataModel, since there is no actual form submission.
To solve the first problem, Seam implements the notion of a page action, but this does not solve the second. It is possible to work around this by passing a request parameter and requerying for the selected object on the server-side, and in some cases (like the Seam blog example application), this is the best approach. Since it is RESTful and does not require server-side state, bookmarking is supported. In other cases, where bookmarking is unnecessary, @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"/>
Copy to Clipboard Toggle word wrap
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"/>
Copy to Clipboard Toggle word wrap
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"/>
Copy to Clipboard Toggle word wrap
The link automatically propagates the selected row of a DataModel inside <h:dataTable>:
<s:link view="/hotel.xhtml" action="#{hotelSearch.selectHotel}" 
   value="#{hotel.name}"/>
Copy to Clipboard Toggle word wrap
You can leave the scope of an existing conversation:
<s:link view="/main.xhtml" propagation="none"/>
Copy to Clipboard Toggle word wrap
You can begin, end, or nest conversations:
<s:link action="#{issueEditor.viewComment}" propagation="nest"/>
Copy to Clipboard Toggle word wrap
If the link begins a conversation, you can specify the use of a particular pageflow:
<s:link action="#{documentEditor.getDocument}" propagation="begin" 
   pageflow="EditDocument"/>
Copy to Clipboard Toggle word wrap
The taskInstance attribute is for use in jBPM task lists, as follows. See Section 1.8, “A complete application featuring Seam and jBPM: the DVD Store example” for an example.
<s:link action="#{documentApproval.approveOrReject}" 
   taskInstance="#{task}"/>
Copy to Clipboard Toggle word wrap
Finally, use <s:button> if you want the "link" rendered as a button:
<s:button action="#{login.logout}" value="Logout"/>
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat