Java 如何在JSF2.2中实现加载页面
我想在JSF web应用程序中实现一个类似gmail的加载页面Java 如何在JSF2.2中实现加载页面,java,jsf,jsf-2,primefaces,Java,Jsf,Jsf 2,Primefaces,我想在JSF web应用程序中实现一个类似gmail的加载页面 用户输入登录名和密码,我带他进入一个带有进度条的简单页面(加载应用程序页面) 进度条100%点击后,将显示应用程序页面 (点击100%表示它根据应用程序页面的初始化进度获得进度值) 现在,我真正需要什么来实现这一点,支持bean范围、facelets数量、faces配置 其他信息: 我正在使用primefaces4.0 我正在使用WebFilter: @WebFilter(filterName=“AuthFilter”,urlPa
- 我正在使用
primefaces4.0
- 我正在使用WebFilter: @WebFilter(filterName=“AuthFilter”,urlPatterns)= {“*.xhtml”})将未连接的用户重定向到登录页面
这是我迄今为止尝试过的,但没有成功(应用程序在加载页面停止) login.xhtml支持bean userBean(会话范围) 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>
这是faces配置
<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>
/loader.xhtml
#{userBean.oncomplete}
/AppPlace.xhtml
/AppPlace.xhtml
#{dyna.killView}
成功
/login.xhtml
看看Primefaces提供的解决方案,即。在您的情况下,我不会使用
init()
方法@PostConstruct
,一旦客户端被转发到loaderPage.xhtml
,我就会调用init()
方法。从那以后,你可以调用getProgress()
我认为这是一个清晰明了的问题,尽管没有人能回答。我不建议让JSF做“progress”的事情。。。我认为您可能需要客户端解决方案。。也许像这样,我想了解查看范围的托管bean的init方法的进度,客户端解决方案会有什么帮助?当页面达到100%时,您可以进行更新,将某些组件的一些呈现的属性设置为true。
@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>