Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将包含的xhtml与托管JSFbean绑定?_Jsf_Javabeans - Fatal编程技术网

如何将包含的xhtml与托管JSFbean绑定?

如何将包含的xhtml与托管JSFbean绑定?,jsf,javabeans,Jsf,Javabeans,我的应用程序中的某些字段在实体之间是通用的。我不想将它们从一个xhtml复制到另一个xhtml,所以我创建了一个xhtml,然后将其包含在需要的地方。我面临的挑战是如何将包含xhtml的bean连接到支持表单的bean 这里只是一个简单的例子。球员和教练是独立的实体,有专用的xhtml文件。它们都有一个名为firstName的字段,并且都有一个Save按钮。这两个元素位于单独的common.xhtml文件中 <h:inputText value="#{playerBean.player.f

我的应用程序中的某些字段在实体之间是通用的。我不想将它们从一个xhtml复制到另一个xhtml,所以我创建了一个xhtml,然后将其包含在需要的地方。我面临的挑战是如何将包含xhtml的bean连接到支持表单的bean

这里只是一个简单的例子。球员和教练是独立的实体,有专用的xhtml文件。它们都有一个名为
firstName
的字段,并且都有一个
Save
按钮。这两个元素位于单独的
common.xhtml
文件中

<h:inputText value="#{playerBean.player.firstName}" '/>
<h:commandButton value="Save" action="#{playerBean.save}" />

您可以通过参数将适当的bean传递给包含的XHTML文件。在您的案例中使用此选项:

<ui:include source="common.xhtml">
  <ui:param name="commonBean" value="#{playerBean}"/> <!-- or coachBean in second case -->
</ui:include>