You need to sign in to do that
Don't have an account?
mritz
using apex:repeat with inputText
I want to save values from dynamically generated input text into list<decimal> using repeat.
please have a look on the following code and suggest changes.
What i want to acheive is that i can gather input values for "Capitals" and "revenues" from the user and save it in apex and do some calculation on it.
I know that apex:repeat value="{!capitals},{!revenues}" is not working.
But i dnt know any approach to gather input in two lists simultaneously.
Any solution based on maps will be fine.
please have a look on the following code and suggest changes.
Apex Class public class myClass1{ public string out1{get;set;} public list<decimal> capitals{get;set;} public list<decimal> revenues{get;set;} public myClass1(){ out1='No way'; capitals=new list<decimal>(5); revenues=new list<decimal>(5); for(integer i=0;i<5;i++){ capitals[i]=revenues[i]=0; } } public void goDynamic(){ out1=String.valueOf(capitals[1]); } } Visual Force Page <apex:page controller="myClass1" showHeader="false" doctype="HTML-5.0"> <apex:form id="form"> <apex:tabPanel > <apex:tab label="one"> <p>Tab one Content</p> <apex:outputtext id="out1" value="{!out1}" escape="false"/> <apex:commandButton value="addRow" rerender="dataTable,out1"/> <apex:commandButton value="goDynamic" action="{!goDynamic}" rerender="dataTable,out1,rpt"/> <table id="dataTable" style="border:2px solid green"> <tr> <th colspan="2">Capital</th> <th colspan="2">Revenue</th> </tr> <apex:repeat value="{!capitals},{!revenue}" var="c,r" id="rpt"> <tr> <td colspan="2"><apex:inputtext value="{!capitals[c]}"/></td> <td colspan="2"><apex:inputtext value="{!revenues[r]}" /></td> </tr> </apex:repeat> </table> </apex:tab> <apex:tab label="two"> </apex:tab> </apex:tabPanel> </apex:form> </apex:page>
What i want to acheive is that i can gather input values for "Capitals" and "revenues" from the user and save it in apex and do some calculation on it.
I know that apex:repeat value="{!capitals},{!revenues}" is not working.
But i dnt know any approach to gather input in two lists simultaneously.
Any solution based on maps will be fine.
Please use wrapper class.
See this link https://developer.salesforce.com/page/Wrapper_Class
Let us know if it helps.
For your case it would be .
Let us know if it helps.
How to implement this within a class?
Use this as Inner Class.
(Given that i want to store 5 different values in each list i.e capitals & revenues)
Suggest changes if any.
It would be great if you practice wrapper class from https://developer.salesforce.com/page/Wrapper_Class
and then use it for your requirement.