2011-08-31 74 views
1

我的代码片段当用于<f:ajax>包含未知ID:someid在<ui:repeat>

<ui:repeat var="o"> 
    <h:panelGroup id="someid"> 
     <ui:repeat> 
     // HTML 
     </ui:repeat> 
    </h:panelGroup> 

    <div> 
     <h:form> 
      <h:commandButton action="#{o.doSomething}"> 
       <f:ajax event="action" render=":someid" /> 
      </h:commandButton> 
     <h:form> 
    </div> 
</ui:repeat> 

为什么不<f:ajax>找到someid

回答

2

这是不可能的。 <ui:repeat>预先使用其自己的ID和索引的客户端ID。所有这些panelgroups获取ID,如j_id1:0:someidj_id1:1:someidj_id1:2:someid,等下应该在您的特定结构的工作:

<f:ajax render=":#{component.parent.parent.clientId}:someid" /> 

这将动态前置<ui:repeat>目前的客户端ID。但它只适用于与MyFaces而不是Mojarra一起使用。在Mojarra,<ui:repeat>在很多方面都被打破了。他们已经安排了许多修补程序,为2.2。

另一种方法是将它们组合在一个像<h:form>这样的常见NamingContainer组件中,以便您可以使用相对ID。

<ui:repeat var="o"> 
    <h:form> 
     <h:panelGroup id="someid"> 
      <ui:repeat> 
       // HTML 
      </ui:repeat> 
     </h:panelGroup> 

     <div> 
      <h:commandButton action="#{o.doSomething}"> 
       <f:ajax event="action" render="someid" /> 
      </h:commandButton> 
     </div> 
    <h:form> 
</ui:repeat> 
+0

谢谢。但我想渲染整个外部UI:重复。那么,我该怎么做呢? – user917383

+0

哦?这个问题你没有说清楚。只需将外部''放在''中,并使用'render =“:foo”'(或其*真实客户端ID,右键单击浏览器中的页面并执行* View来源*找到它)。 – BalusC

相关问题