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
caterina ferrigno 8caterina ferrigno 8 

Passing Parameters to AddRow Method

Hello,
I don't understand how to solve this problem :
I have this VF page 
User-added image
I want that if i click on the button '+' in the section "righe offerta" to which corresponds Numero voce  = 00000024,
in the section "righe offerta selezionate" appears the same number (00000024), or  if i click on the button '+' to which corresponds Numero voce  = 00000027,in the section "righe offerta selezionate" appears the number (00000027), and so on.
The problem is that whatever is the button I click, in the section "righe offerta selezionate" appears always the same number 00000024.

This is my code
-VF page
 <apex:page StandardController="Fattura__c" extensions="CreaNewFatturaCtrl" showHeader="false">
<apex:pageBlock title="Nuova fattura">   
<apex:form id="frm">
    <Apex:actionFunction name="addRow" action="{!AddRow}" >    
        <Apex:param name="selectedIndex" value="" assignTo="{!selectedIndex}"/>               
    </apex:actionfunction>
                         
    <apex:pageBlock id="pageid">          
    <apex:pageBlockButtons location="Both">
                <apex:commandButton value="Salva" action="{!saveRecord}"/>
                <apex:commandButton value="Annulla" action="{!cancelRecord}"/>                  
    </apex:pageBlockButtons>

 <apex:variable value="{!0}" var="i"/>    
  <apex:pageBlockSection columns="1"  title="Righe offerta" collapsible="FALSE">                                                                                                  <apex:pageblocktable value="{!qli}" var="roff" >   
                    <apex:column headervalue="Aggiungi">                         
                    <apex:commandButton value="+" action="{!AddRow}"  rerender="pageid"   />                                                                             
                    </apex:column> 
                                          
                    <apex:column value="{!roff.LineNumber}" headervalue="Numero voce" />
                    <apex:column value="{!roff.ListPrice}" headervalue="Prezzo di listino" />
                    <apex:column value="{!roff.UnitPrice}" headervalue="Prezzo di vendita" />
                    <apex:column value="{!roff.Quantity}" headervalue="Quantità" />
                    <apex:column value="{!roff.Importo_IVA__c}" headervalue="Importo IVA" />
                    <apex:column value="{!roff.Totale__c}" headervalue="Totale" />
                    <apex:column value="{!roff.Importo_ancora_da_fatturare__c}" headervalue="Importo ancora da fatturare" />
                    <apex:column value="{!roff.Description}" headervalue="Descrizione riga offerta" /> 
                                                        
        </apex:pageblocktable> 
        <apex:variable value="{!i+1}" var="i"/>   
        </apex:pageblockSection> 
                     
 <apex:pageBlockSection columns="4"  title="Righe offerta selezionate" collapsible="FALSE" >
  <apex:repeat var="qliA" value="{!ListaQLIdaCompilare}">
     <apex:inputField value="{!qliA.LineNumber}"/>
     <apex:inputField value="{!qliA.Descrizione__c}"/>
     <apex:inputField value="{!qliA.N_Ordine_Cliente__c}" />
     <apex:inputField value="{!qliA.perc_da_fatturare__c}"/>
  </apex:repeat>
 </apex:pageblockSection>                                                                              
   </apex:pageBlock>                                              
  </apex:form>                                                            
 </apex:pageBlock>
</apex:page>


-Apex Class
public class CreaNewFatturaCtrl { 

      public Fattura__c fattura {get;set;}    
      private String idQuote;
      private String idQuotelineitem;               
      public List <QuoteLineItem> qli {get;set;}      
      public QuoteLineItem qli1 {get;set;}       
      public Integer selectedIndex   {get;set;}
      public List<QuoteLineItem> ListaQLIdaCompilare {get; set;}
                                                                                                                              
     public CreaNewFatturaCtrl(ApexPages.StandardController stdcontroller) {                
        idQuote= ApexPages.currentPage().getParameters().get('idQuote');              
        ListaQLIdaCompilare = new List<QuoteLineItem>();   
        this.fattura=(Fattura__c) stdController.getRecord();        
        fattura.preventivo__c = idQuote;                                     
        qli = [SELECT Id, LineNumber, ListPrice, UnitPrice, Quantity, Importo_IVA__c, Importo_ancora_da_fatturare__c , Totale__c, Description 
                FROM QuoteLineItem WHERE Quote.Id = :idQuote];                                
        }
                       
          public ApexPages.PageReference addRow(){
          selectedIndex = 0;     
          idQuotelineitem= qli[Integer.ValueOf(selectedIndex)].id;          
          qli1 = [SELECT Id, LineNumber, Descrizione__c, N_Ordine_Cliente__c, perc_da_fatturare__c FROM QuoteLineItem WHERE           QuoteLineItem.Id = :idQuotelineitem LIMIT 1];                                                   
          ListaQLIdaCompilare.add(qli1);
          system.debug('++++++++++++++++++++++++++++++ apexpages.currentpage() '+ apexpages.currentpage().getparameters().get('selectedIndex') );           
          return null;                                 
          }  
                                                                             
        public ApexPages.PageReference saveRecord() {
         insert fattura;
         return new PageReference('/'+fattura.id);
        }
     
        public ApexPages.PageReference cancelRecord() {
         return new PageReference('/'+idQuote);
        }           
}

Do you know the solution to the problem?
Thank you!! 
 
Dushyant SonwarDushyant Sonwar

Hi Caterina,

You need to pass value to your controller .
See below :

<apex:commandButton value="+" >
    <apex:actionSupport event="onclick" action="{!AddRow}" rerender="pageid"> 
<apex:param name="arg" assignto="{!yourvariable}" value=""/>

</apex:actionSupport>
</apex:commandButton>
 


Hope this helps

 

 

caterina ferrigno 8caterina ferrigno 8
Hi Dushyant, 
unfortunately it doesn't work.