【问题标题】:<f:ajax> contains an unknown id with compositecomponent<f:ajax> 包含带有复合组件的未知 id
【发布时间】:2012-09-13 13:59:00
【问题描述】:

我在表单中使用复合组件,我想使用ajax调用,当复合组件值发生变化时,重置相关字段的模型值并重新渲染对应的组件(空的)。但似乎我只能为组件设置渲染;不是为了另一个;我不断收到&lt;f:ajax&gt; contains an unknown id 'ticketForm:gfhId'

我有一个复合组件loc:Location(简体)

<!DOCTYPE...
<html...
<h:body>
  <composite:interface>
    <composite:attribute name="visibleFieldValue" required="true" />
    <composite:attribute name="hiddenFieldValue" required="true" />
    <composite:clientBehavior name="changeLocation" event="click" targets="updateButton deleteButton"/>
  </composite:interface>
  <composite:implementation>
    <div id="#{cc.clientId}">
      <h:inputText id="visibleId" value="#{cc.attrs.visibleFieldValue}"
        readonly="true" onfocus="#{rich:component('popUpPnl')}.show('', {top:'100px', left:'250px'});"/>
      <h:inputHidden id="hiddenId" value="#{cc.attrs.hiddenFieldValue}"
        converter="es.caib.gesma.gesman.data.converter.LocationConverter" />
      <a4j:commandButton id="deleteButton"
        image="/resources/images/icons/textfield_delete.png" alt="Borrar"/>
      <h:commandButton id="updateButton" value="Update"/>

      ...
    </composite:implementation>
  </body>
</html>

组件在表单ticketForm中使用如下:

<loc:location id="locationId"
  hiddenFieldValue="#{ticketCtrl.ticket.location}"
  visibleFieldValue="#{ticketCtrl.ticket.locationDescription}">
  <f:ajax event="changeLocation" render="ticketForm:gfhId" execute="@this"
    listener="#{ticketCtrl.locationListener}"/>
</loc:location>

将渲染设置为@all@form 会导致不显示异常,但不会渲染gfhId 组件(我认为它仅将其应用于复合组件)。

为了比较,我已经使用相同形式的 inputText 组件设置了所需的行为:

<h:inputText id="contactId" value="#{ticketCtrl.ticket.contactPerson}">
  <a4j:ajax event="change" render=":ticketForm:gfhId"
    execute="@this" listener="#{ticketCtrl.locationListener}"/>
</h:inputText>

有什么想法吗?提前致谢。

【问题讨论】:

    标签: jsf-2 composite-component


    【解决方案1】:

    &lt;f:ajax&gt;executerender 中的所有相对客户端 ID(即不以 : 开头的那些)都相对于父 NamingContainer 组件进行解析。复合组件隐式为NamingContainer。所以它基本上是在&lt;cc:implementation&gt; 的上下文中寻找ticketForm:gfhId,但是没有。

    改为使用绝对客户端 ID。

    <f:ajax ... render=":ticketForm:gfhId" />
    

    另见:

    【讨论】:

    • 我们不能有一个BalusC 标签吗?请问?
    • :) 您可以在搜索词中添加user:157882
    猜你喜欢
    • 2012-04-09
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    • 2013-01-28
    • 2012-10-30
    • 2011-11-23
    • 1970-01-01
    相关资源
    最近更新 更多