【发布时间】:2012-07-12 06:31:07
【问题描述】:
大家好,我遇到了一个非常奇怪的问题。我创建了一个客户端模板 facelet 和模板 facelet。但是当我运行我的网页时,它不会插入定义的标签。我的意思是不工作。这是我的代码
插入.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title>facelet example </title>
</head>
<body>
<ui:insert name="face1"> </ui:insert>
<ui:insert name="face2"> </ui:insert>
<ui:insert name="face3"> </ui:insert>
<ui:insert name="face4"> </ui:insert>
</body>
</html>
撰写.xhtml:
<!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://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<body>
<ui:composition template="insert.xhtml">
<ui:define name="face1">
<center><h2>Facelet</h2></center>
<h3>Welcome to the Facelet world..........</h3>
</ui:define>
<ui:define name="face2">Enter UserID :<br/>
<h:inputText id="it" /><br/><br/>
</ui:define>
<ui:define name="face3">Enter Password :<br/>
<h:inputSecret id="is" /><br/><br/>
</ui:define>
<ui:define name="face4">
<h:commandButton id="b" value="Submit" />
</ui:define>
</ui:composition>
</body>
</html>
但是当我在 insert.xhtml 中使用 <include src="compose.xhtml"> 标记时,它会显示完整的 facelet。但包含标记只有在我这样写时才有效
<insert name="face1">
<include src="compose.xhtml"/>
</insert>
如果我在包含之前删除 insert 标记,那么包含也不起作用。我对 JSF 2.0 facelets 的这种奇怪行为感到恶心。请帮助我
谢谢
【问题讨论】:
标签: jsf jakarta-ee jsf-2 facelets