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>
<apex:column rendered="false">
<apex:inputHidden id="hiddenUniqueKey" value="{!s.uniqueKey}"/>
</apex:column>
</apex:pageblockTable>
<apex:pageBlockButtons location="top">
<apex:commandButton value="Delete Selected" onClick="saveFilterJS('delete'); return false;"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
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');
}
}
if(!atLeastOneItemSelected){
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.'));
}else{
getShoppingCartList();
}
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);
}
}