Java jsf - “找不到带有表达式的组件”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25090806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 23:36:47  来源:igfitidea点击:

jsf - "Cannot find component with expression"

javajsfprimefaces

提问by rsb2097

I'm using PrimeFaces and a component within one layoutUnitmust update another component which is within another layoutUnit:

我正在使用 PrimeFaces 并且一个组件中的一个组件layoutUnit必须更新另一个组件中的另一个组件layoutUnit

<p:layout>
  <p:layoutUnit position="west" size="275" resizable="true" closable="true" collapsible="true">
    <h:form id="formWest">
      <div id="west">
        <ui:insert name="west"></ui:insert>
      </div>
    </h:form>
  </p:layoutUnit>
  <p:layoutUnit id="layout_center" position="center">
    <h:form id="formCenter">
      <div id="content">
        <ui:insert name="content"></ui:insert>
      </div>
    </h:form>
  </p:layoutUnit>
</p:layout>

The error message is: Caused by: javax.faces.FacesException: Cannot find component with expression "formWest:execucao" referenced from "formCenter:form:mapaGoogle".

错误信息是: Caused by: javax.faces.FacesException: Cannot find component with expression "formWest:execucao" referenced from "formCenter:form:mapaGoogle".

The components that need to be updated are inside tdso I did <td jsf:id="execucao">, for example.

需要更新的组件在里面,td所以我做了<td jsf:id="execucao">,例如。

采纳答案by Kishor Prakash

As you know when you refer components from another form you have to attach the form ID to the component Id.

如您所知,当您从另一个表单引用组件时,您必须将表单 ID 附加到组件 ID。

You also need to know that you have to attach another :before the form ID, when refereing the compnent in different form.

您还需要知道:,当以不同的形式引用组件时,您必须在表单 ID 之前附加另一个。

Example:

例子:

<h:form id="form1">
    <p:inputText id="input1" />
</h:form>

Now if I want to update the input1from another form I have to use:

现在,如果我想input1从另一种形式更新我必须使用:

:form1:input1

Example:

例子:

<h:form id="form2">
   <p:commandButton update=":form1:input1" />
</h:form>

In your case use:

在你的情况下使用:

:formWest:execucao