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:组合标签在客户端页面?
如果我里面添加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
,如果我在模板中添加文本“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写它的页面上。
但是,如果我在其中一个客户端页面尝试相同的方式,他们不工作。
如果我在模板中放入
在模板头部添加了并运行了模板,并且刷新了模板。现在的问题是它会刷新每个客户端页面吗? –
是元刷新似乎在模板及其所有客户端页面上工作。我所要做的就是在NetBeans中重建项目。干杯。 –
我在模板中尝试过 hello,并且仍然不可见。 –
我认为它的netbeans问题......也许它根本没有使用template.xhtml。尝试在模板中将“默认标题”更改为“默认标题2”,并且在打开template.xhtml时未反映该更改。 –
在另一个没有使用primefaces的项目似乎工作。 –