Activity Forums Salesforce® Discussions How can i access variable in a Salesforce visualforce page defined in wrapper class?

  • Manpreet

    Member
    May 2, 2017 at 1:45 pm

    Hi suraj,

    You can do this by iterating the wrapper list in the visualforce page and then accessing variables using (.) dot notation.Something Like this:

    /**WRAPPER**/
    public class productsList2_wrapper{
    public product2 prdt2{get;set;}
    public integer quantity {get;set;}

    public productsList2_wrapper(product2 product){
    prdt2 = product;
    quantity = 0;
    }
    }

    public List<productsList2_wrapper> getProducts(){
    productsWrapperList = new List<productsList2_wrapper>();
    for(product2 prdtObj : [SELECT Name,Images__c FROM Product2 LIMIT 10]){
    //Addition to List
    productsWrapperList.add(new productsList2_wrapper(prdtObj));
    }
    return productsWrapperList;
    }

    VF Page :

    <div class="tableRepeat">
    <apex:repeat value="{!productsList}" var="prodLstInCart" >
    <div>
    <div class="CartProdRecords">
    <div style="position: absolute;">{!prodLstInCart.prdt2.Name} </div>
    <div class="quantityInCart"> {!prodLstInCart.quantity} </div>
    <div class="deleteProdsInCart">
    <input type="button" id="deleteProdsInCart" value="x" onclick="deleteProdsInCartCall('{!prodLstInCart.prdt2.Id}')" />
    </div>
    </div>
    </div>
    </apex:repeat>

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos