I have a Visualforce page with apex pageblock table and I need the data from two input columns every time user clicks on delete selected button.

The input data from the column "checkboxColumn" is never passed to the controller. Not sure what is wrong with the below code..

<apex:form >
   <apex:actionFunction name="removeMethodController" action="{!removeFromShoppingCart}" rerender="selected" status="deleteActionStatusDiv" immediate="true"/>
    <apex:outputPanel id="mainBody">        
        <apex:pageBlock title="Selected {!$ObjectType.Product2.LabelPlural}" id="selected">
                <apex:pageMessages /> 
                    <apex:pageblockTable value="{!shoppingCartList}" var="s" id="selectedProductsDiv">
                        <apex:column id="checkBoxColumn">                            
                            <apex:inputCheckbox value="{!s.selected}"/>
                        <apex:column rendered="false">
                            <apex:inputHidden id="hiddenUniqueKey" value="{!s.uniqueKey}"/>
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Delete Selected" onClick="saveFilterJS('delete'); return false;"/>

Here is the removeFromShoppingCart method:

public PageReference removeFromShoppingCart(){    
    List<OpportunityLineItem> selectedOppLItems = new List<OpportunityLineItem>();        
    boolean atLeastOneItemSelected = false;
    for(Integer i =0; i< shoppingCartList.size(); i++){
        WrapperShoppingCart w = shoppingCartList.get(i);
        if(w.selected == true){
            System.debug(LoggingLevel.ERROR,'### This part of code is never entered');
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING,'Please select atleast one record before clicking on Delete selected button or click cancel button to go back.'));
    return null;

and this is the wrapper class:

public class WrapperShoppingCart{
    public opportunityLineItem oppLineitem {get;set;}
    public Boolean selected {get;set;}
    public Long uniqueKey{get;set;}

    public WrapperShoppingCart(opportunityLineItem oLineItem ){
        oppLineitem = oLineItem;
        selected = false;
        Datetime currentDateTime = Datetime.now();
        String text = String.valueOf(currentDateTime.yearGmt());
        text = text + String.valueOf(currentDateTime.monthGmt());
        text = text + String.valueOf(currentDateTime.dayGmt());
        text = text + String.valueOf(currentDateTime.hourGmt());
        text = text + String.valueOf(currentDateTime.minuteGmt());
        text = text + String.valueOf(currentDateTime.secondGmt());
        text = text + String.valueOf(currentDateTime.millisecondGmt());
        uniqueKey = Long.valueOf(text);            

1 Answer 1


When you use immediate="true" usually the required parameters in the form is neglected and the form is posted to server.

This also stops the input parameters to be passed to controller.

Try removing the immediate="true" and execute your code to see that the selected values got passed to the controller.

Hope it helps.

  • if there are two rows in the table and user did not fill all the required columns in both the rows but he wants to delete only the 2nd row..so how do I achieve this?..If I remove immediate = "true" actionFunction is never even executed and it shows error message saying that data needs to be filled in for all the required columns.
    – javanoob
    Commented Jul 27, 2015 at 15:43
  • Then you should remove the required="true" from the input fields and do the validation using javascript or jquery. This way user won't be seeing any error messages and all the validations will reside in client side itself. Commented Jul 27, 2015 at 15:48
  • Thanks for the idea Vignesh! I will try this and post here on how it goes. Thanks for your time.
    – javanoob
    Commented Jul 27, 2015 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .