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
Cesar Ramirez Vasquez005391619375684564Cesar Ramirez Vasquez005391619375684564 

How can i retrieve value from a repeat list in VF to my controller so i can update the invoice line in my method?

This is my scenario, i have the following VF page, i need to get the value of Cantidad in my controller so i can update the quantity selected by the user:
<apex:page action="{!init}" controller="mainControllerV2" showHeader="false" standardStylesheets="true">

<apex:outputPanel id="the_outputpanel2">
    <apex:pageBlock >
    <p>Paso #4 - Agregue los productos a la factura.</p>
      <apex:form >
        <apex:pageBlockTable id="srch_id" value="{!ListaSRCH}" var="o">
            <apex:column value="{!o.CantidadExistencia__c}"> <apex:facet name="header"> </apex:facet>
            <apex:inputField value="{!o.CantidadExistencia__c}"/>
            <apex:column value="{!o.Codigo__c}"> <apex:facet name="header"> </apex:facet> </apex:column>
            <apex:column value="{!o.Descripcion__c}"> <apex:facet name="header"> </apex:facet> </apex:column>
            <apex:column value="{!o.Precio__c}"> <apex:facet name="header"></apex:facet> </apex:column>
            <apex:column headerValue="Opciones" >
                    <apex:commandLink value="AGREGAR" action="{!add2carrito}">
                            <apex:actionSupport event="onclic" rerender="the_outputpanel3"/>    
                            <apex:param name="idz"   assignTo="{!current_prod}" value="{!}"  />                               

Im not sure whats the value of value="{!o.CantidadExistencia__c}" im pretty new to apex i dont know what variable it references to.

This is my controllers methods:

public List<Producto__c> getListaSRCH(){
Operaciones O = new Operaciones();
//ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error al buscar'));
return O.busqueda(STR_SRCH);

public PageReference add2carrito(){
//se tiene el id
//Producto__c P = new Producto__c();

  Producto__c P =[select id, Name, Precio__c, Codigo__c, Tipo__c,CantidadExistencia__c, Descripcion__c from Producto__c where id=:current_prod limit 1];
   if (P.CantidadExistencia__c != 0) {
    P.CantidadExistencia__c = 1;
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'El item :'+ P.Descripcion__c + ' se encuentra agotado en el inventario.'));
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'El item :'+ P.Descripcion__c +' no tiene existencias en el inventario. Asegurese de ingresar existencia antes de facturar.'));
catch(exception j){ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error al agregar elemento al carrito'+j));}
return null;

public Integer is_present(Producto__c P){
  Integer counter = 0;
  Integer answ = 0;
  boolean present = false;
  for( Producto__c C : CARRITO){
    if(C.Codigo__c == P.Codigo__c){answ = counter;present=true;}
    else{counter ++;}
  return answ;

public void insertarLinea()
        List<Linea__c> lines = new list<Linea__c>(); // crea una lista con las lineas de la factura
            //Para cada producto C en carrito
            for(Producto__c C : CARRITO) {

                   Linea__c Line = new Linea__c ();
                   Line.Cantidad__c = C.CantidadExistencia__c;
                   Line.Factura__c =;                 
                   Line.Monto_Colones__c = C.Precio__c;
                   Line.Monto_Dolares__c = 0;
                   Line.Producto__c =;
                   lines.add(Line); // adding line to list
                 Producto__c P =[select id, CantidadExistencia__c from Producto__c where limit 1];
                 P.CantidadExistencia__c = P.CantidadExistencia__c - Line.Cantidad__c;         
                 update (P);                        


            insert (lines); // Insertamos la lista lineas asi evitamos hacer un insert por cada registro que haya en CARRITO
        catch(Exception a)
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error al insertar la linea. '+a));


How can i proceed any ideas, suggestions, i have tried sending the value through apex:param but i dont really knew how to proceed i have been stucked with this for 3 days know.

Thank you

You can call below action function from apex:commandLink onClick event or you can use <a href='' onclick="echo({!})";>check</a>

<apex:actionFunction name="echo" action="{!add2carrito}" reRender="the_outputpanel3" status="myStatus">
<apex:param name="firstParam" assignTo="{!current_prod}" value="" />

Note : keep all above action function's attributes
Cesar Ramirez Vasquez005391619375684564Cesar Ramirez Vasquez005391619375684564
Hi, thanks for your reply i dont understand how to apply your example and how do i get the value in the controller when is change by the user ?
I have implemented sample code for you, here when user click on "Do Some Thing" link then controller method will get called and record Id also passed into controller (this is working code )

###### Controller  ######
public class Controller {
      public List<Account> accList {get;set;}

      public Id accountId{get;set;}
      public Controller (){
          accList = [select id,name, Phone, Description from Account limit 10];  
      public PageReference doSomething() {
          return null;

###### VF Page ######

<apex:page controller = "Controller">
        <apex:pageBlock id ="pbSec">
            <apex:PageBlockTable value="{!accList }" var ="acc">
                <apex:column headerValue="Name">
                    <apex:outputField value="{!acc.Name}"/>
                 <apex:column headerValue="Phone">
                    <apex:outputField value="{!acc.Phone}"/>
                <apex:column headerValue="Description ">
                    <apex:outputField value="{!acc.Description }"/>
                <apex:column headerValue="Action">
                     <a href="" onclick="echo('{!}');">Do Something </a>
        <apex:actionFunction name="echo" action="{!doSomething}" reRender="pbSec" status="myStatus">
            <apex:param name="firstParam" assignTo="{!accountId}" value="" />

Please let me know if you have any confusion.