I am trying to show a list of 5 of Accounts and along with it is an inputText. Now when I try to use the apex:repeat to display the 5 Accounts, along with the inputText (accPrice) and tried to loop the Account to see if each accPrice I put tied with each Account, it is not. The only value it is reading is the last field in the apex:repeat. Can you help me with this please?
Here is my VF Page:
<apex:page controller="ListsMapsController">
<apex:outputPanel id="box" layout="block">
<apex:pageMessages/>
<apex:form >
<apex:commandButton action="{!ShowAccounts}" value="Show" id="firstbutton" rerender="box"/>
<apex:repeat value="{!accountList}" var="acc">
<apex:outputField value="{!acc.Name}"/>
<apex:inputText value="{!accPrice}"/><br/>
</apex:repeat>
<apex:commandButton action="{!submitFieldData}" value="Submit" id="button" rerender="box"/>
</apex:form>
</apex:outputPanel>
</apex:page>
Here is my Controller:
public class ListsMapsController {
public Decimal accPrice {get; set;}
public List<Account> accountList {get; set;}
public void ShowAccounts()
{
accountList = [SELECT ID, NAME FROM Account LIMIT 5];
}
public void submitFieldData()
{
for(Account acc : accountList)
{
system.debug('hb.Name: ' + acc.Name);
system.debug('hdbPrice: ' + accPrice);
}
}
}
Answers would much appreciated! Thank you in advance!