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
venkatasubhashkvenkatasubhashk 

Apex repeat not saving values from form

 

hi

 

i have follwing code , when saved it is taking the valuse from controller but not from the form

 

i used Apex repete here

 

and when i use apex page block table i am able to save the values from Form also..

 is there a way to save values through apex repete also...

<apex:page standardController="Opportunity" extensions="TVA_Billing_Itemssubhash" sidebar="false">
<apex:form>
 <apex:pageMessages />
 <apex:pageBlock title="Add Billing Items">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}" rerender="error" />
            </apex:pageBlockButtons>
   <table border='0'>
  
  <tr>
   <apex:repeat value="{!opps}" var="q">
   <tr bgcolor='#E0FFFF'>
  <th>Opportunity Name</th>
  <th>Header Opportunity</th>
  <th>Stage</th>
  <th>Account</th>
  <th>Closedate</th>
  <th>Probability</th>
  <th>Amount</th>
  </tr>
  <td><apex:outputField value=" {!q.name}"/></td>
  <td> <apex:inputField value=" {!q.Header_Opportunity__c}"/> </td>
  <td><apex:inputField value=" {!q.stagename}"/>  </td>
  <td> <apex:inputField value=" {!q.Accountid}"/>   </td>
  <td> <apex:inputField value="{!q.CloseDate}"/>   </td>  
  <td>  <apex:inputField value="{!q.Probability}"/> </td>   
  <td>  <apex:inputField value="{!q.amount}"/>   </td> 
  
  
  <tr bgcolor='#E0FFFF'>
  
   <th></th>
   <th>Product</th>
    <th>Unit Price</th>
    <th>Quantity</th>
     <th></th> <th></th> <th></th>
   </tr>
   <apex:repeat value="{!oppli}" var="qa" rows="{!opportunity.Opp_Line_Items_Count__c}">
   
   <tr>
  <td>
  </td>
   <td><apex:outputField value=" {!qa.Product_Code__c}"/></td>
   <td><apex:inputField value=" {!qa.unitprice}"/></td>
    <td><apex:inputField value=" {!qa.quantity}"/></td>

 </tr>
 </apex:repeat>
 
   
  
   
   </apex:repeat>
   
  </tr>
   
   </table>
   
            </apex:pageBlock>
   
    </apex:form>
</apex:page>

 

public class TVA_Billing_Itemssubhash {

   public List<Opportunity> Opps  {get; set;}
    
    static Integer cnt2;
  public List<OpportunitylineItem> Oppli  {get; set;}
    public  Opportunity [] op;
    
    
   
    string id;
    decimal i =0; 
    decimal j = 0;
  
    public TVA_Billing_Itemssubhash (ApexPages.StandardController myController) 
    {
    this.id = ApexPages.currentPage().getParameters().get('id');
    //current page Opportunity and Opp Line Items and Price Book Entry ID
    Opportunity o =[select id,name,date_of_close_date__c ,Final_Closed_Date__c,Week_End_Day__c,Estimated_Start_Date__c,Account.name,Round_off__c,Year_of_close_date__c,Month_Of_Closedate__c,stagename,CloseDate,pricebook2id,amount,probability,Header_Opportunity__c,Accountid,Opp_Line_Items_Count__c,Billing_Contact__c,No_Of_Months_for_Billing__c from Opportunity where id=:id];
    OpportunitylineItem[] oli = [select id,Product_Name__c,TotalPrice,ListPrice,PricebookEntry.name,Quantity,PricebookEntry.Product2.Name , PricebookEntry.Product2.id, UnitPrice,PricebookEntryId,Opportunityid,Quote_Original_List_Price__c  from OpportunityLineItem where Opportunityid=:o.id] ;
    
 
  
     Opps = new List<Opportunity>();
     Oppli =new List<OpportunitylineItem>();
    
         
       
       
        
        for(i=0;i<o.No_Of_Months_for_Billing__c;i++)
        {
       
     
         Opportunity LitOrd = new Opportunity();
         LitOrd.stagename = 'Billing-Planned';
      
         LitOrd.probability =100;
         LitOrd.amount = o.amount;
       
        LitOrd.closedate = o.closedate;
        
       
      
         Opps.add(LitOrd);
          }
          
         
        for(j=0;j<((o.Opp_Line_Items_Count__c/oli.size())*o.No_Of_Months_for_Billing__c);j++){
        
         for(opportunitylineitem oli1:oli){

         OpportunitylineItem LitOrdch = new OpportunitylineItem();
                  
       
         LitOrdch.quantity = oli1.quantity;
         LitOrdch.unitprice = oli1.unitprice; 
     
         LitOrdch.opportunityid = o.id;
       
       
        LitOrdch.PricebookEntryId=oli1.PricebookEntryId;
        LitOrdch.Product_Code__c = oli1.PricebookEntry.name;
       
    
         Oppli.add(LitOrdch); 
         
        }
       }
       
       
       }   
     

   
    public PageReference save() 
    {
       
     try{     
         insert opps;
         
           insert Oppli;
          
          
        }    

      catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Oops An Error Occured!'));
      return null;
    } 
     
         return(new ApexPages.StandardController(Opps[0])).view();
       
 }
 
 
        
        }