Steve Tee
Steve Tee

Reputation: 13

Render ids generated by nested <f:ajax> inside <ui:repeat> do not match those generated by JSF

My form contains a dropdown list inside a ui:repeat component. When any list item is selected, an f:ajax call triggers a refresh of both dropdown list and several other components inside ui:repeat . Im struggling to work out the correct id format for the f:ajax render="???????" (see facelet view below). Any help would be appreciated.

Ive supplied raw source view of the rendered screen (actual JSF ids) and a facelet view showing the same components as coded.

Browser Source View

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

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

Ive tried the following but none have worked...

  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"

Upvotes: 1

Views: 2005

Answers (1)

BalusC
BalusC

Reputation: 1109625

The <ui:repeat> is by itself a NamingContainer. You can just reference a client ID relative to the <ui:repeat> itself.

Your code example is confusing, you're basically attempting to perform render="@this", so here's a different and more elaborate example wherein another menu component and some input component are been ajax-updated on change of the current menu:

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

See also:

Upvotes: 2

Related Questions