Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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
Ajax 在JSF中更新自己的复合组件中的表单_Ajax_Jsf 2_Facelets_Composite Component - Fatal编程技术网

Ajax 在JSF中更新自己的复合组件中的表单

Ajax 在JSF中更新自己的复合组件中的表单,ajax,jsf-2,facelets,composite-component,Ajax,Jsf 2,Facelets,Composite Component,我有以下(简化,但问题可以演示)组件my:slot <composite:interface> </composite:interface> <composite:implementation> <h:panelGroup styleClass="xxx" layout="block"> <composite:insertChildren/> </h:panelGroup> </composite:im

我有以下(简化,但问题可以演示)组件
my:slot

<composite:interface>
</composite:interface>
<composite:implementation>
  <h:panelGroup styleClass="xxx" layout="block">
    <composite:insertChildren/>
  </h:panelGroup>
</composite:implementation>

现在,我想将此组件与两个表单一起使用:

<my:slot>
    <h:form id="f3">
        <p:commandButton value="update f4" update=":f4"/>  
    </h:form>
</my:slot>
<my:slot>
  <h:form id="f4">Form f4</h:form>
</my:slot>

表格f4

使用此代码,我得到一个错误
无法找到标识符为“:f4”的组件,该标识符是从“j_idt11:f3:j_idt12”
引用的。如果我在
my:slot
之外使用
h:form id=“f4”
就可以了。如何在如上所示的自己的组件中使用
h:form

复合组件本身也与
类似。查看生成的HTML输出。他们的ID在孩子的ID前面

您需要为复合组件提供一个固定的ID,以便JSF不会自动生成一个不可预测的ID,然后在
更新中引用它

<my:slot id="slot1">
    <h:form id="f3">
        <p:commandButton value="update f4" update=":slot2:f4"/>  
    </h:form>
</my:slot>
<my:slot id="slot2">
  <h:form id="f4">Form f4</h:form>
</my:slot>

表格f4
另见:

复合组件本身也与
类似。查看生成的HTML输出。他们的ID在孩子的ID前面

您需要为复合组件提供一个固定的ID,以便JSF不会自动生成一个不可预测的ID,然后在
更新中引用它

<my:slot id="slot1">
    <h:form id="f3">
        <p:commandButton value="update f4" update=":slot2:f4"/>  
    </h:form>
</my:slot>
<my:slot id="slot2">
  <h:form id="f4">Form f4</h:form>
</my:slot>

表格f4
另见: