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

Chapter 24. Remoting


Seam uses Asynchronous JavaScript and XML (AJAX) to remotely access components from a web page. The framework for this functionality requires very little development effort — you can make your components AJAX-accessible with simple annotations. This chapter describes the steps required to build an AJAX-enabled web page, and explains the Seam Remoting framework in further detail.

24.1. Configuration

To use remoting, you must first configure your Seam Resource Servlet in your web.xml file:
<servlet>
  <servlet-name>Seam Resource Servlet</servlet-name> 
  <servlet-class>
    org.jboss.seam.servlet.SeamResourceServlet
  </servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>Seam Resource Servlet</servlet-name>
  <url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
Copy to Clipboard Toggle word wrap
Next, import the necessary JavaScript into your web page. A minimum of two scripts must be imported. The first contains all client-side framework code, which enables remoting functionality:
<script type="text/javascript" 
        src="seam/resource/remoting/resource/remote.js">
</script>
Copy to Clipboard Toggle word wrap
The second contains the stubs and type definitions for the components you wish to call. This is generated dynamically, based on the local interface of your components, and includes type definitions for all classes that can be used to call the remotable methods of the interface. The script name reflects your component name. For example, if you annotate a stateless session bean with @Name("customerAction"), your script tag should look like this:
<script type="text/javascript" 
        src="seam/resource/remoting/interface.js?customerAction">
</script>
Copy to Clipboard Toggle word wrap
If you want to access more than one component from the same page, include them all as parameters of your script tag:
<script type="text/javascript" 
        src="seam/resource/remoting/interface.js?customerAction&accountAction">
</script>
Copy to Clipboard Toggle word wrap
You can also use the s:remote tag to import the required JavaScript. Separate each component or class name that you want to import with a comma:
<s:remote include="customerAction,accountAction"/>
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat