You need to sign in to do that
Don't have an account?

Why delete row action not call apex function?
visualforce page:
apex function:
Log debug output
Why delete row action not call apex function?
<apex:form > <apex:pageBlock title="Your Carts:"> <apex:pageblockTable value="{!MapProducts}" var="a"> <apex:column > <apex:image width="100" height="100" value="{!URLFOR($Resource.ProductImage, 'ProductImage/' & MapProducts[a]['ImageName__c'])}"></apex:image> </apex:column> <apex:column headerValue="Name" value="{!MapProducts[a]['Name']}"/> <apex:column headerValue="Price" value="{!MapProducts[a]['Price__c']}"/> <apex:column headerValue="Amount" > <apex:inputText style="text-align:right;width:100px;" value="{!MapProducts[a]['Amount']}"/> </apex:column> <apex:column headerValue="Money" value="{!MapProducts[a]['Total']}"/> <apex:column > <apex:commandLink action="{!deleteItem}" reRender="MapProducts" ><apex:param assignTo="{!iKey}" value="{!a}" name="assignvalue" /> Remove Row</apex:commandLink> </apex:column> </apex:pageblockTable> <apex:pageBlock title="Total Money:"> <apex:outputText >{!iTotalMoney}</apex:outputText> </apex:pageBlock> </apex:pageBlock> </apex:form>
apex function:
public void deleteItem() { System.Debug('deleteItem') ; iTotalMoney=0; System.Debug(iKey) ; MapProducts.remove(iKey); for (Integer key : MapProducts.keySet()) { iTotalMoney +=Double.valueOf(MapProducts.get(key).get('Total')); } }
Log debug output
43.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO 03:14:43.0 (94306)|USER_INFO|[EXTERNAL]|0057F000002yTNz|daitb@vnitsolutions.com|Pacific Standard Time|GMT-07:00 03:14:43.0 (138242)|EXECUTION_STARTED 03:14:43.0 (143358)|CODE_UNIT_STARTED|[EXTERNAL]|0667F000009PMhv|VF: /apex/carts 03:14:43.0 (360015)|VF_DESERIALIZE_VIEWSTATE_BEGIN|0667F000009PMhv 03:14:43.0 (7435075)|VF_DESERIALIZE_VIEWSTATE_END 03:14:43.0 (9840462)|SYSTEM_MODE_ENTER|true 03:14:43.0 (14743313)|SYSTEM_MODE_ENTER|true 03:14:43.0 (15488240)|VF_SERIALIZE_VIEWSTATE_BEGIN|0667F000009PMhv 03:14:43.0 (17250235)|VF_SERIALIZE_VIEWSTATE_END 03:14:43.20 (20160362)|CUMULATIVE_LIMIT_USAGE 03:14:43.20 (20160362)|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 0 out of 100 Number of query rows: 0 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 0 out of 150 Number of DML rows: 0 out of 10000 Maximum CPU time: 0 out of 10000 Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 100 Number of Email Invocations: 0 out of 10 Number of future calls: 0 out of 50 Number of queueable jobs added to the queue: 0 out of 50 Number of Mobile Apex push calls: 0 out of 10 03:14:43.20 (20160362)|CUMULATIVE_LIMIT_USAGE_END 03:14:43.0 (20198901)|CODE_UNIT_FINISHED|VF: /apex/carts 03:14:43.0 (21042239)|EXECUTION_FINISHEDlog not exist text: deleteItem
Why delete row action not call apex function?
We need to provide the ID of particular attribute to refresh, I have added form ID and refer the same as reRender value.
All Answers
Please add one more attribute "ID" in <apex:commandLink> and it will work. Like below
Thanks,
Gaurav
Skype: gaurav62990
You need to change your line number 16 to this. Hope it helps you.
<apex:commandLink action="{!deleteItem}" reRender="MapProducts" ><apex:param assignTo="{!iKey}" value="{!a.Id}" name="assignvalue" /> Remove Row</apex:commandLink>
Make sure in your apex class you have to use getter setter method like this.
public String iKey{get;set;}
Please select as best answer if it helps you.
Thank you,
Ajay Dubedi.
public Map<Integer, Map<String,String>> MapProducts {get;set;}
public Double iTotalMoney {get;set;}
public Integer iKey{get;set;}
But reRender not update to web page.
Why?
We need to provide the ID of particular attribute to refresh, I have added form ID and refer the same as reRender value.
You need to assign an id to render the particular section.
Please mark as best answer if it helps you.
Thank You,
Ajay Dubedi