Java 如何在用户刷新时更新jsf列表
我有一个JSF1.2命令链接Java 如何在用户刷新时更新jsf列表,java,jsf,refresh,Java,Jsf,Refresh,我有一个JSF1.2命令链接 <h:commandLink id="cars" action="${swapViewHandler.myFunction1}"> <h:commandLink id="ships" action="${swapViewHandler.myFunction2}"> myFunction1使用cars填充swapViewHandler.listA并导航到cars.xhtml <navigation-rule>
<h:commandLink id="cars" action="${swapViewHandler.myFunction1}">
<h:commandLink id="ships" action="${swapViewHandler.myFunction2}">
myFunction1使用cars填充swapViewHandler.listA并导航到cars.xhtml
<navigation-rule>
<navigation-case>
<from-outcome>cars</from-outcome>
<to-view-id>cars.xhtml</to-view-id>
<redirect />
</navigation-case>
汽车
cars.xhtml
myFunction2使用ships和
导航到ships.xhtml
<navigation-rule>
<navigation-case>
<from-outcome>ships</from-outcome>
<to-view-id>hips.xhtml</to-view-id>
<redirect />
</navigation-case>
船舶
hips.xhtml
我需要处理用户刷新(F5),以便在
调用cars.xhtml myFunction1并重新填充listA(使用cars)
当ships.xhtml刷新时,调用myFunction2并重新填充listA(使用ships)
cars.xhtml和ships.xhtml具有相同的backingbean(swapviewhandler)
它们都包含
<c:forEach id="tablePicList" items="${swapViewHandler.listA}" var="entity" varStatus ="status">
每个视图都应该有自己的支持bean。将bean放在请求范围中,并在其(post)构造函数中执行该工作。然后,将在每个新的GET请求上调用它。例如
公共类CarHandler{
私家车名单;
@EJB
私家车服务;
@施工后
公共void init(){
cars=carService.list();
}
// ...
}
不要忘记将命令链接更改为正常的输出链接。它还将为您提供额外的SEO点数,因为它显然涉及纯页面间导航和可书签/刷新的GET请求
汽车
船舶
如果列表依赖于某个请求参数或会话范围的托管bean,那么您应该将其作为
faces config.xml
中的
注入到支持bean中。它将在@PostConstruct
方法中可用(但不在构造函数中!)。每个视图都应该有自己的支持bean。将bean放在请求范围中,并在其(post)构造函数中执行该工作。然后,将在每个新的GET请求上调用它。例如
公共类CarHandler{
私家车名单;
@EJB
私家车服务;
@施工后
公共void init(){
cars=carService.list();
}
// ...
}
不要忘记将命令链接更改为正常的输出链接。它还将为您提供额外的SEO点数,因为它显然涉及纯页面间导航和可书签/刷新的GET请求
汽车
船舶
如果列表依赖于某个请求参数或会话范围的托管bean,那么您应该将其作为faces config.xml
中的
注入到支持bean中。它将在@PostConstruct
方法中可用(但不在构造函数中!)