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
另见: