【发布时间】:2014-05-02 05:10:15
【问题描述】:
我想在我的 JSF Web 应用程序中实现 加载页面,例如 gmail。
- 用户输入登录名和密码,我将他带到一个带有进度条的简单页面(正在加载应用程序页面)。
- 一旦进度条达到 100%,就会显示应用程序页面。
(命中100%表示根据应用页面的初始化进度获取进度值)。
现在,我真正需要什么来实现它,支持 bean 范围、facelets 的数量、faces-config..
附加信息:
- 我正在使用
Primefaces 4.0 -
我正在使用 WebFilter :
@WebFilter(filterName = "AuthFilter", urlPatterns = {"*.xhtml"}) 将未连接的用户重定向到登录页面。
这是我迄今为止尝试过的,但没有运气(应用程序在加载页面中停止)。
login.xhtml 支持 bean userBean(会话范围)。
userBean.doLogin() ==> return "loaderPage";
loaderPage.xhtml无后备bean
<h:body>
<p:progressBar widgetVar="pbAjax" ajax="true"
value="#{dyna.progress}"
labelTemplate="{value}%"
styleClass="animated">
<p:ajax event="complete" listener="#{userBean.onComplete}" />
</p:progressBar>
</h:body>
dyna.progress 应用程序页面 支持 bean(会话范围)
这就是我在 loadingPage.xhtml
的进度条上设置值的方式@ManagedBean(name = "dyna", eager = true)
@SessionScoped
@PostConstruct
public void init() {
try {
progress = 0;
etatdateOptions = ListsMaker.getDateFilters();
progress = 10;
optionspatState = ListsMaker.getPatientStates();
progress = 20;
optionsCotpatState = ListsMaker.getPayementStates();
progress = 30;
...}
这是面孔配置
<faces-config version="2.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_2.xsd">
<navigation-rule>
<from-view-id>/loader.xhtml</from-view-id>
<navigation-case>
<from-action>#{userBean.oncomplete}</from-action>
<to-view-id>/AppPlace.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/AppPlace.xhtml</from-view-id>
<navigation-case>
<from-action>#{dyna.killView}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/login.xhtml</to-view-id>
<redirect>
</redirect>
</navigation-case>
</navigation-rule>
【问题讨论】:
-
我认为这是一个干净而清晰的问题,尽管没有人能回答。
-
我不建议让 JSF 做“进步”的事情......我认为你可能需要一个客户端解决方案......也许像这样 gayadesign.com/diy/queryloader-preload-your-website-in-style
-
我想获取视图范围托管 bean 的 init 方法的进度,客户端解决方案将如何提供帮助?
标签: java jsf jsf-2 primefaces