function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GeneEAGeneEA 

Accessing inputField Values Created Inside apex:repeat

Hello.

I need help in getting a VF page controller to access inputField values that are created inside an apex:repeat. I know that when converted to HTML, each of those inputFields has an ID that auto-increments, but I don't know how to get the controller to access those values.

Here is the code snippet from the VF page in question that contains the apex:repeat generated inputFields:

 

<tr>
<td colspan="3"><apex:actionStatus id="msgStatus2"layout="block">
<apex:facet name="start">
<apex:image url="{!URLFOR($Resource.ChatStyles, 'images/indicator_2.gif')}" />
</apex:facet>
<apex:facet name="stop">
<apex:outputPanel id="additionalCategoryView1" layout="block">
																		<table width="741" border="0">
<tr>
<td colspan="2">
<table border="0" width="741">
<apex:repeat value="{!categoryList}" rendered="{!categoryList.size>0}" var="additionalCategory" id="additionalCategoryId">																						<tr>																						<td align="right" width="156" style="padding: 0px 5px 0px 0px;" class="FormDescriptions">Additional Category<font style="font-size: 11px;" color="red">*</font></td>																				<td colspan="2" width="200" style="padding: 0px 5px 0px 0px;"><apex:inputField id="categoryname" value="{!additionalCategory.Category_Name__c}" required="false" styleClass="formbox_cream">
																								<apex:actionSupport event="onchange" action="{!packageSummary}" immediate="true" reRender="selectedPackageSummary" status="counterStatus" />
																							</apex:inputField> <apex:outputPanel rendered="{!step2Flag && additionalCategory.Category_Name__c==null}">
																								<div class="errorMsg"><strong>Error:</strong>Value Cannot be null</div>
<script>document.getElementById('{!$Component.categoryname}').style.borderColor = '#ff0000';</script>
																							</apex:outputPanel></td>
																							<td align="right" width="115" class="bodySmall" style="padding: 0px 0px 0px 10px;">Primary Zip Code<font style="font-size: 11px;" color="red">*</font><br /> (50 mile radius)</td>
																							<td width="60" style="padding: 0px 5px 2px 0px;">
																							<apex:inputField id="addPromaryZIP" style="width:50px" value="{!additionalCategory.Primary_ZIP_Code__c}" required="false" styleClass="formbox_cream" onblur="return validateZIP(this)">
																								<apex:actionSupport event="onchange" action="{!packageSummary}" reRender="selectedPackageSummary status="counterStatus" />
																							</apex:inputField> <apex:outputPanel rendered="{!step2Flag && additionalCategory.Primary_ZIP_Code__c==null}">
																								<div class="errorMsg"><strong>Error:</strong> Value Cannot be null</div>
																								<script>document.getElementById('{!$Component.addPromaryZIP}').style.borderColor = '#ff0000'; </script>
																							</apex:outputPanel></td>
																							<td align="right" width="123" class="bodySmall" style="padding: 0px 5px 0px 8px;"> Additional Zip Code<br /> (50 mile radius)</td>
																							<td width="33" style="padding: 0px 5px 0px 0px;">
																							<apex:inputField style="width:50px" value="{!additionalCategory.Additional_ZIP_Code__c}" required="false"  styleClass="formbox_cream" onblur="return validateZIP(this)">
																								<apex:actionSupport event="onchange" action="{!packageSummary}" reRender="selectedPackageSummary" status="counterStatus" />
																							</apex:inputField></td>
																							<td align="right" width="50" style="padding: 0px 5px 0px 5px;" class="bodySmall"><apex:commandLink immediate="true" id="deleteCat" value="Remove" action="{!deleteAdditionalCategory}" reRender="additionalCategoryView1,selectedPackageSummary status="msgStatus2">
																								<apex:param name="CategoryID" value="{!additionalCategory.Id}" />
																							</apex:commandLink></td>
																						</tr>
																						<tr>
																							<td align="right" style="padding: 0px 5px 0px 0px;" class="FormDescriptions"> <p>&nbsp;</p>
																							</td>
																							<td colspan="2" class="bodySmall" align="right"> <strong>Select a Package for this category:</strong></td>
																							<td colspan="3"><apex:selectRadio value="{!additionalCategory.Select_a_Package__c}" required="false" styleClass="formbox_cream" onclick="document.getElementById('{!$Component.primaryCatPackage}').focus();">
																								<apex:selectOption itemValue="15% Package" itemLabel="15% Option ($99)" />
																								<apex:selectOption itemValue="20% Package" itemLabel="20% Option ($0)" />
																								<apex:actionSupport event="onchange" action="{!packageSummary}" reRender="selectedPackageSummary,initialSetupFees,memberAgreement" status="counterStatus" />
																							</apex:selectRadio></td>
																						</tr>
																					</apex:repeat>
																				</table>
																				</td>
																			</tr>
																		</table>
																	</apex:outputPanel>
																</apex:facet>
															</apex:actionStatus></td>
														</tr>

 
Any help would be greatly appreciated. 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You can access the values entered via the list that is backing the apex:repeat - the edits the user makes are already present by the time your controller method executes.

 

I wrote a blog post on this a little while ago at:

 

http://bobbuzzard.blogspot.co.uk/2011/03/persisting-list-edits-in-visualforce.html

All Answers

bob_buzzardbob_buzzard

You can access the values entered via the list that is backing the apex:repeat - the edits the user makes are already present by the time your controller method executes.

 

I wrote a blog post on this a little while ago at:

 

http://bobbuzzard.blogspot.co.uk/2011/03/persisting-list-edits-in-visualforce.html

This was selected as the best answer
MandyKoolMandyKool

Hi,

 

If your controller if you have a getter and setter method for "CategoryList" then you should be able to get the inputField values in your list. Once user clicks on "Save" or any other button on your VF page all setter methods for the page will be called. 

 

Once the setter method for the "CategoryList" is called; it will contain new record instances (with new values that user has entered on your page). So you can iterate over your list and get those values.

 

Hope this is what you are looking for!!

GeneEAGeneEA

Thank you for the quick replies. It worked.