JSF/a4j 混搭 - 查看状态 ID 已过期
我们有一组 Web 模块,它们彼此是对等应用程序。我们使用 jQuery 将它们混合在一起。这些不同的模块都使用 JSF。不同的模块可以部署在不同的Java EE应用服务器上。
想象一个用于开设帐户的 JSF 页面。该页面可能会利用客户搜索功能来查找要为其开设帐户的客户。带有帐户开立表单的 JSF 页面由一个 Web 模块提供,而客户端搜索页面由另一个 Web 模块提供。
...jsf page loaded from http://openaccount.com/openForm.xhtml
... code to load a search from from elsewhere...
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('#search_gadget').load('http://search.com/searchForm.xhtml');
});
</script>
<search_gadget/>
<br/> .. the rest of the open account form...
...searchForm 和 openForm 都是 JSF/a4j 页面。
现在,问题在于,当 searchForm 'gadget' 确实调用 a4j 来执行搜索并且它返回新的视图状态 id 时,openForm.xhtml 的视图状态 id 也会更新。当使用 openForm.xhtml 将表单发布到服务器时,视图状态 ID 不同步(因为它们最后是通过 a4j 调用不同的 Web 模块更新的,该模块具有不同的服务器端视图状态)。
有没有一种方法可以隔离适合上述方式的视图状态 id?我们希望能够将 jsf 视图状态与来自不同 Web 模块的混搭组件隔离开来?
We have a group of web modules that are peer applications to one another. We mash them together using jQuery. These differing modules all use JSF. The different modules may be deployed on different Java EE application servers.
Imagine a JSF page for opening an account. That page might make use of a customer search feature to look up the customer the account is to be opened for. The JSF page with the account open form on it is served from one web module, and the client search page is served up from another.
...jsf page loaded from http://openaccount.com/openForm.xhtml
... code to load a search from from elsewhere...
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('#search_gadget').load('http://search.com/searchForm.xhtml');
});
</script>
<search_gadget/>
<br/> .. the rest of the open account form...
...both searchForm and openForm are JSF/a4j pages.
Now, the trouble is that when the searchForm 'gadget' does makes a4j calls to perform searches and new view state id's are returned by it, the view state id's of the openForm.xhtml are updated as well. When the openForm.xhtml is then used to post the form to the server the view state id's are out of synch (since they were last updated by a4j calls to a different web module, which has a differing server side view state).
Is there a way to isolate view state id's appropriate for the manner described above? where we want to be able to isolate jsf view state to mashed-in components from different web modules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以,这就是我们最终要做的...
我们所有的离散 Web 模块都具有相同的域,但每个模块都有一个唯一的上下文根 www.bank.com/waw/accounts/somepage.xhtml,或 www.bank.com/waw/transfers/somepage.xhtml。我们使用这些上下文根来确定哪些表单应该更新其视图状态。
像这样(这个解决方案不适用于所有想要混搭的人,但它适用于我们)...
So, here is what we ended up doing...
All our discrete web modules have the same domain, but each has a unique context root www.bank.com/waw/accounts/somepage.xhtml, or www.bank.com/waw/transfers/somepage.xhtml. We use these context roots to scope which forms should have their view state updated.
like so (this solution wont work for all ppl that want to mash, but it works for us)...