小编Joc*_*itz的帖子

JSF <f:event type ="preRenderView"...>有效,但没有加载正确的CSS

我试图用每个视图检查身份验证

<f:event type="preRenderView" listener="{#loginControl.checkAuthentication}" /> 
Run Code Online (Sandbox Code Playgroud)

标签.

机制有效,但看起来很糟糕,似乎缺少一些CSS.当我删除支票时,我的页面会按原样显示.

这是我的一个观点,其中是检查身份验证:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<f:event listener="#{loginControl.checkAuthorization}" type="preRenderView" />
<h:head>
...
Run Code Online (Sandbox Code Playgroud)

调用以下方法:

public void checkAuthorization(ComponentSystemEvent evt){
  FacesContext ctx = FacesContext.getCurrentInstance();
  ConfigurableNavigationHandler nav = (ConfigurableNavigationHandler)      
  ctx.getApplication().getNavigationHandler();

  // navigate to login-screen
  if(this.user==null){          
   nav.performNavigation("login");
  } else {
   nav.performNavigation("welcome");
  }
}
Run Code Online (Sandbox Code Playgroud)

输出是这样的:

http://www.convince-it.de/Auswahl_002.jpeg

http://www.convince-it.de/Auswahl_003.jpeg

正如您所看到的那样,当我检查授权时,组件不会被渲染.第一张图片是启用授权检查时生成的视图的屏幕截图.第二个视图是未经授权检查的渲染视图,但具有所需的外观.

有任何想法吗?

css jsf primefaces prerender

3
推荐指数
1
解决办法
8868
查看次数

标签 统计

css ×1

jsf ×1

prerender ×1

primefaces ×1