嵌套<f:ajax>在<ui:repeat>中生成的渲染ID与JSF生成的渲染ID不匹配</ui:repeat> </f:ajax>

时间:2013-05-02 18:06:41

标签: ajax jsf-2

我的表单在ui:repeat组件中包含一个下拉列表。当选择任何列表项时,f:ajax调用会触发刷新下拉列表和ui:repeat内的其他几个组件。我正在努力找出f的正确id格式:ajax render =“???????” (见下面的facelet视图)。任何帮助,将不胜感激。

我提供了渲染屏幕的原始源视图(实际的JSF ID)和一个显示与编码相同的组件的facelet视图。

浏览器源视图

<form id="GeneralMedicalHistory" name="GeneralMedicalHistory" method="post" action="..." 

<span id="GeneralMedicalHistory:GeneralMedicalHistory_P"> 

<span id="GeneralMedicalHistory:medhist">

   <table border="0" class="table_form">

   <select id="GeneralMedicalHistory:RPTK:0:MedicalCondition" name="GeneralMedicalHistory:RPTK:0:MedicalCondition" >  ---> TARGET ID  (UI:REPEAT)

Facelet视图

<h:form id ="GeneralMedicalHistory">
<h:panelGroup id="GeneralMedicalHistory_P">
<h:panelGroup id="medhist">
<ui:repeat value="#{f.repeatingItemGroups['MedicalHistory'][1]}" var="repeatKey" id="RPTK" >      
<h:commandLink action="remove_repeating_ig" rendered="${f.items[removeOid].isNew and repeatKey != '1'}"></>
<table border="0" class="table_form"> 
 <h:selectOneMenu value="${f.items[oid].value}" id="MedicalCondition" >  
   <f:selectItems value="${f.items[oid].codeListItems}"/>
   <f:ajax render="?????????" event="click" listener="#{f.clearModelValuesViaAjax}"  /> 
 </h:selectOneMenu>
</table>
</h:panelGroup>     
</h:panelGroup>      
</h:form>

我尝试过以下但没有一个有效......

  1. f:ajax render =“GeneralMedicalHistory:RPTK:0:MedicalCondition”
  2. f:ajax render =“:GeneralMedicalHistory:RPTK:0:MedicalCondition”
  3. f:ajax render =“GeneralMedicalHistory_P:medhist:RPTK:0:MedicalCondition”
  4. f:ajax render =“:GeneralMedicalHistory_P:medhist:RPTK:0:MedicalCondition”
  5. f:ajax render =“GeneralMedicalHistory:GeneralMedicalHistory_P:medhist:RPTK:0:MedicalCondition”
  6. f:ajax render =“:GeneralMedicalHistory:GeneralMedicalHistory_P:medhist:RPTK:0:MedicalCondition”

1 个答案:

答案 0 :(得分:2)

<ui:repeat>本身就是NamingContainer。您只需引用相对于<ui:repeat>本身的客户端ID即可。

您的代码示例令人困惑,您基本上是在尝试执行render="@this",所以这里有一个不同的更详细的示例,其中另一个菜单组件和一些输入组件在更改当前菜单时已经更新了ajax:

<ui:repeat ...>
    <h:selectOneMenu ...>
        ...
        <f:ajax ... render="otherMenu someInput" />
    </h:selectOneMenu>
    <h:selectOneMenu id="otherMenu" ... />
    <h:inputText id="someInput" ... />
</ui:repeat>

另见: