我使用 JSF 和 PrimeFaces 开发一个简单的应用程序,这是我面临的一个问题:
这些是具有以下Person属性的托管 Bean:
ClientBean EmployeeBean我有person.xhtml显示一个人的数据的。我将a和包括person.xhtml在内。我需要创建两个,因为我使用不同的豆。我想做的是这样的:client.xhtmlemployee.xhtmlperson.xhtml
<c:set var="person" value="clientBean.person" />
<ui:include src="person.xhtml"/>
<c:set var="person" value="employeeBean.person" />
<ui:include src="person.xhtml"/>
Run Code Online (Sandbox Code Playgroud)
在我的person.xhtml我可以使用#{person.name},#{person.dateOfBirth}. <c:set/>我搜索了一下,在JSF中使用是错误的。
有人可以帮忙吗?
将其传递为<ui:param>.
<ui:include src="person.xhtml">
<ui:param name="person" value="#{clientBean.person}" />
</ui:include>
<ui:include src="person.xhtml">
<ui:param name="person" value="#{employeeBean.person}" />
</ui:include>
Run Code Online (Sandbox Code Playgroud)
如有必要,请注册person.xhtml为标记文件以使其看起来更好,另请参阅何时使用 <ui:include>、标记文件、复合组件和/或自定义组件?
<my:personForm value="#{clientBean.person}" />
<my:personForm value="#{employeeBean.person}" />
Run Code Online (Sandbox Code Playgroud)
请注意重复的组件 ID 错误。另请参阅在同一命名容器中重用 Facelets 组合时避免重复 id。
| 归档时间: |
|
| 查看次数: |
1347 次 |
| 最近记录: |