【问题标题】:Updating form in own composite-components in JSF在 JSF 中自己的复合组件中更新表单
【发布时间】:2013-05-29 09:39:59
【问题描述】:

我有以下(简化,但问题可以演示)组件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>

使用此代码,我收到错误 Cannot find component with identifier ":f4" referenced from "j_idt11:f3:j_idt12"。如果我在my:slot 之外使用h:form id="f4" 就可以了。如上所示,如何在自己的组件中使用h:form

【问题讨论】:

    标签: ajax jsf-2 facelets composite-component


    【解决方案1】:

    复合组件本身也是naming containers,就像&lt;h:form&gt;。查看生成的 HTML 输出。他们的 ID 附加在孩子的 ID 前面。

    你需要给你的复合组件一个固定的 ID,这样 JSF 就不会自动生成一个不可预知的 ID,然后在 update 中引用它。

    <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>
    

    另见:

    【讨论】:

      猜你喜欢
      • 2012-04-01
      • 2012-07-26
      • 2015-01-23
      • 1970-01-01
      • 1970-01-01
      • 2011-07-28
      • 2012-12-31
      • 2012-11-18
      • 1970-01-01
      相关资源
      最近更新 更多