如何使用f:viewParam对GET请求执行操作? [英] How to execute action on GET request with f:viewParam?
问题描述
我目前正在尝试将记录的ID从一页发送到另一页.
I'm currently trying out sending the id of a record from one page to another page.
所以在第1页中,我有这样的东西:
So in the page 1, i have something like this :
<p:column>
<h:link value="#{rpb.map['transNum']}" outcome="TInput.xhtml">
<f:param name="id" value="#{rpb.map['id']}" />
</h:link>
</p:column>
在目标页面(TInput.xhtml)中,我有类似这样的内容来捕获id:
and in the target page (TInput.xhtml), i have something like this to capture the id :
....
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<f:metadata>
<f:viewParam name="id" value="#{tInputBean.id}"></f:viewParam>
</f:metadata>
<h:head>
....
现在,单击链接,转到第2页,第2页由一个视图范围的jsf bean处理.从我的调试开始,这就是发生的顺序:
Now, clicking on the link, goes to page 2, and page 2 is handled by one view-scoped jsf bean. And from my debugging, this is the order of happenning :
- 执行@PostConstruct方法
- 使用从viewParam捕获的ID更新模型(appy请求+验证之后)
我想实现的是: 更新模型后,我想对该记录ID执行查询,获取它的bean及其来自Business Service的详细信息列表.
我想知道我应该在哪里放置查询代码:
I wonder where should i could put my query code :
- 在@PostConstruct方法内部是不可能的,因为从
完成后,将从viewParam捕获的ID设置为模型 - 在模型更新后使用相位监听器吗?
- 使用系统事件?尽管我似乎找不到适合这种情况的
- inside @PostConstruct method is not possible, since the id captured from the viewParam is set to the model after the @PostConstruct method finishes
- use a phase listener on after the model update ?
- use a system event ? although i cant seem to find the appropriate one for this case
请赐教我:)
推荐答案
添加 到
带有 (顺便说一句,与文档相反,参数和异常是可选的,至少在我使用的所有Mojarra 2.x版本中都是如此) 这篇关于如何使用f:viewParam对GET请求执行操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!public void init(ComponentSystemEvent event) throws AbortProcessingException {
// ...
}