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
minkeshminkesh 

Problem with wrapper class

Hello Folks,

 

I hope you all are doing well.

I stuck into one problem. Please Help me to get out of this.

Here is the problem.

 

I have written page and Controller.

 

Her is the code of VF Page :- 

     <table border="1" cellspacing="0" cellpadding="0" width="40%">
            <tr>
                <td > 
                    <b><apex:outputLabel value="Staff,managed by " >{!$User.FirstName} {!$User.LastName}</apex:outputLabel></b>
                </td>
                <td >
                    <b><apex:outputLabel value="Role" /></b> 
                </td>
                <td >
                    <b><apex:outputLabel value="Monthly Salary" /></b> 
                </td>
                <td>
                    <table width="300px;">
                        <tr>
                            <apex:repeat value="{!projectWrapListForHeader}" var="projectHeader" >
                               <td width="180px;">
                                   <apex:outputText value="{!projectHeader.projectRec.Name}" />
                               </td>                
                            </apex:repeat>
                        </tr>
                        <tr>
                            <apex:repeat value="{!projectWrapListForHeader}" var="projectHeader" >
                                <apex:repeat value="{!projectHeader.balanceWrap}" var="bal">
                                    <td width="180px;">
                                         <apex:outputText value="{!bal.balance.Name}"/>
                                    </td>
                                </apex:repeat>
                            </apex:repeat>
                        </tr>
                    </table>
                </td>
            </tr>
            <apex:repeat value="{!staffWrapList}" var="staffVar">
                <tr>
                
                    <td>
                        <apex:outputText >{!staffVar.staff.name}</apex:outputText>
                    </td>
                    <td>
                        <apex:outputText >{!staffVar.staff.Role__c}</apex:outputText>
                    </td>
                    <td>
                        <apex:outputText >{!staffVar.staff.Monthly_Salary_2__c}</apex:outputText>
                    </td>
                    <td>
                        <table width="300px;">
                            <tr>
                                <apex:repeat value="{!ProjectWrapListForHeader}" var="projectHeader1" >
                                   <td width="180px;">
                                   </td>                
                                </apex:repeat>
                            </tr>
                            <tr>
                                <apex:repeat value="{!staffVar.projectWrap}" var="projectHeader" >
                                    <apex:repeat value="{!projectHeader.balanceWrap}" var="ta">
                                        <td width="180px;">
                                           <apex:repeat value="{!ta.timeAllocationList}" var="tal">
                                             <apex:inputText value="{!tal.Percent__c}"/>
                                           </apex:repeat>
<!--                                        <apex:inputText value="{!ta.Percent__c}"/>-->
                                        </td>
                                    </apex:repeat>
                                </apex:repeat>
 

 Here is my controller :-

 

Wrapper class   

public class StaffWrapperClass
    { 
        public Staff__c staff{get;set;}
        public List<ProjectWrapperClass> projectWrap {get;set;}
        public List<Double> percent{get;set;}
        public StaffWrapperClass(){
          staff = new Staff__c();
          projectWrap = new List<ProjectWrapperClass>();
          percent = new List<Double>();
      }
    }
    
   public class ProjectWrapperClass{
        public Project__c projectRec {get;set;} 
        //public List<Balance__c> balance{get;set;}
        public List<BalanceTimeWrapper> balanceWrap{get;set;}
        public ProjectWrapperClass(){
          projectRec = new Project__c();
          //balance = new List<Balance__c>();
          balanceWrap = new List<BalanceTimeWrapper>();
        }
   }
   
   public class BalanceTimeWrapper{
       public Balance__c balance{get;set;}
       //public Time_Allocation__c timeAllocation{get;set;}
       public List<Time_Allocation__c> timeAllocationList{get;set;}
       public BalanceTimeWrapper(){
         balance = new Balance__c();
         //timeAllocation = new Time_Allocation__c();
         timeAllocationList = new List<Time_Allocation__c>();
       }
   }

 

 

 When I clicked on save I want to create seperate time allocation object record.
It is creating record but overriding the last rows text box value.

 

Where i am making mistake ?

 

TIme Allocation Object Stricture :- Balance__c Lookup,Staff LookUp and Percent field which is Text box. So in above case it should generate six records of time allocation with value of percent 1 2 3 4 5 6 but it is generating 456 456.

 

Thanks,

Minkesh