2017-10-16 75 views
0

这里的模板JSF页面模板--html元刷新无法正常工作

<?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:ui="http://xmlns.jcp.org/jsf/facelets" 
     xmlns:h="http://xmlns.jcp.org/jsf/html"> 

    <h:head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />   
     <meta http-equiv="refresh" content="30"> 
     <title><ui:insert name="title">Default Title</ui:insert></title> 
     <h:outputStylesheet library="css" name="jsfcrud.css"/> 
    </h:head> 

    <h:body> 
     <h1> 
      <ui:insert name="title">Default Title</ui:insert> 
     </h1> 
     <p> 
      <ui:insert name="body">Default Body</ui:insert> 
     </p> 
    </h:body> 

</html> 

这里有一个客户端

<?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:ui="http://xmlns.jcp.org/jsf/facelets" 
     xmlns:h="http://xmlns.jcp.org/jsf/html" 
     xmlns:f="http://xmlns.jcp.org/jsf/core" 
     xmlns:p="http://primefaces.org/ui">   
    <ui:composition template="/template.xhtml"> 
     <ui:define name="title"> 
      <h:outputText value="#{bundle.ListPhonerecordTitle}"></h:outputText> 
     </ui:define> 
     <ui:define name="body">     
      <h:form styleClass="jsfcrud_list_form"> 
       <p:poll interval="10" listener="#{phonerecordController.prepareList}" update="@all" /> 
       ... 
       ... 
       ...     
      </h:form> 
     </ui:define> 
    </ui:composition> 

</html> 

当我运行客户端页面元刷新无法正常工作(刷新页面每隔30秒) 。

我试着把元刷新标签放在模板(在h:head内),但是当客户端页面运行时,它不刷新页面。

我应该尝试把元刷新标签内的UI:组合标签在客户端页面?

回答

0

如果我里面添加h的形象:在模板的身体像这样

<?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:ui="http://xmlns.jcp.org/jsf/facelets" 
     xmlns:h="http://xmlns.jcp.org/jsf/html"> 

    <h:head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />   
     <title><ui:insert name="title">Default Title</ui:insert></title> 
     <h:outputStylesheet library="css" name="jsfcrud.css"/> 
    </h:head> 

    <h:body> 
     <h:graphicImage value = "resources/phonegirl1.PNG"/><br /> 
     <h1> 
      <ui:insert name="title">Default Title</ui:insert> 
     </h1> 
     <p> 
      <ui:insert name="body">Default Body</ui:insert> 
     </p> 
    </h:body> 

</html> 

,并尝试在客户端页面图像打开是不存在的。当我运行模板页面时,它也不可见。

这可能有了答案: Template content not displaying

+0

我在模板中尝试过 hello,并且仍然不可见。 –

+0

我认为它的netbeans问题......也许它根本没有使用template.xhtml。尝试在模板中将“默认标题”更改为“默认标题2”,并且在打开template.xhtml时未反映该更改。 –

+0

在另一个没有使用primefaces的项目似乎工作。 –

0

,如果我在模板中添加文本“Hello World”像这样

<?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:ui="http://xmlns.jcp.org/jsf/facelets" 
     xmlns:h="http://xmlns.jcp.org/jsf/html"> 

    <h:head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />   
     <title><ui:insert name="title">Default Title</ui:insert></title> 
     <h:outputStylesheet library="css" name="jsfcrud.css"/>       
    </h:head> 

    <h:body> 
     Hello World! 
     <h1> 
      <ui:insert name="title">Default Title</ui:insert> 
     </h1>   
     <p> 
      <ui:insert name="body">Default Body</ui:insert> 
     </p> 
    </h:body> 

</html> 

参照模板每个客户端页面的Hello World写它的页面上。

但是,如果我在其中一个客户端页面尝试相同的方式,他们不工作。

+0

如果我在模板中放入 apple,并将其放在嗨,苹果在客户端工作。现在的挑战是如果我把元刷新标签放在模板中,它会在所有页面上工作吗? –

+0

在模板头部添加了并运行了模板,并且刷新了模板。现在的问题是它会刷新每个客户端页面吗? –

+0

是元刷新似乎在模板及其所有客户端页面上工作。我所要做的就是在NetBeans中重建项目。干杯。 –