Dei*_*bys 9 parameters facelets include jsf-2 backing-beans
我有一个可能在不同应用程序中使用的Facelet.我不复制它,但重复使用它.我需要传递将视图作为参数进行管理的辅助bean,因为某些逻辑可能会根据使用它的应用程序而有所不同.
我不想使用复合组件,只是包含Facelet并指定哪个bean将管理视图.我怎样才能做到这一点?
让我举个例子:
<ui:composition template="/resources/common/templates/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich" xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<ui:define name="content">
<!-- somehow establish the backing bean that will manage formView.xhtml -->
<!-- f:set assign="ParameterBean" value="#{Bean}" / -->
<ui:include src="formView.xhtml" />
</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
formView.xhtml:
<ui:composition template="/resources/common/templates/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich" xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<ui:define name="content">
<h:outputText value="#{ParameterBean.texto}" />
</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
Bal*_*usC 23
你可以用<ui:param>它.它需要嵌套在<ui:include>.
<ui:include src="formView.xhtml">
<ui:param name="ParameterBean" value="#{Bean}" />
</ui:include>
Run Code Online (Sandbox Code Playgroud)
与具体问题无关,标准Java命名约定规定实例变量名称必须以小写字母开头.你应该以这样的方式分别更改代码parameterBean和#{bean}将被使用.
| 归档时间: |
|
| 查看次数: |
12167 次 |
| 最近记录: |