You need to sign in to do that
Don't have an account?
Noor Fazli
Database updates on actionsupport are not getting displayed on rerendering of form
We are using actionsupport to make database changes and we want to display those changes on the rerendering of the form.
Rerendering is working in the sense that its doing the page refresh but it does not reflect the database changes. When we do manual refresh than we are able to see the changes. What should be done.(actually I have tried using outputPanels also, but it looks like database update and page refresh are disconnected events). How to display new values on page refresh?
-- Here is the Visual force code
Rerendering is working in the sense that its doing the page refresh but it does not reflect the database changes. When we do manual refresh than we are able to see the changes. What should be done.(actually I have tried using outputPanels also, but it looks like database update and page refresh are disconnected events). How to display new values on page refresh?
-- Here is the Visual force code
<apex:form id="mainFormId"> <apex:pageBlock id="NR" > <apex:pageBlockButtons location="Top"> <apex:commandButton value="Notification to Invoice" action="{!processSelected}" immediate="false"> <apex:actionSupport event="onclick" reRender="mainFormId"/> </apex:commandButton> </apex:pageBlockButtons> <apex:pageBlockSection title="Non Recurring Billings" id="NRbill"/> <apex:commandButton action="{!NewBillNR}" value="New Non Recurring Billings" immediate="false"> <apex:param name="type" value="Non Recurring"/> </apex:commandButton> <apex:pageBlockTable value="{!wrapRecords_NR}" var="Rec"> <apex:column > <apex:facet name="Action">Action</apex:facet> <apex:inputCheckbox value="{!Rec.selected}" id="inputId"/> <apex:outputText value="{!Rec.bill.billingLink__c}" escape="false" styleClass="actionLink"/> | <apex:commandLink onclick="return DeleteBill('{!Rec.bill.Id}');" value="Del" id="theCommandLink"/> </apex:column> <apex:column > <apex:facet name="header">Description</apex:facet> <apex:outputText value="{!Rec.bill.Name}"></apex:outputText> </apex:column> <apex:outputLabel value="{!Rec.bill.Name}" id="RecId" /> <apex:outputLink value="{!Rec.bill.billingLink__c}" >Your Hyperlink Text</apex:outputLink> <apex:column > <apex:facet name="header">Billing Amount per Period(USD)</apex:facet> <apex:outputText value="{!Rec.bill.Billing_Amount_Per_Period__c}"/> </apex:column> <apex:column headerValue="NTI"> <apex:outputField value="{!Rec.bill.Notification_to_Invoice__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> Here is the excerpt from Controller code: public PageReference processSelected(){ //We create a new list of Contacts that we be populated only with Contacts if they are selected selectedbill = new List<Billing__c>(); selListId = new List<String>(); //We will cycle through our list of Non Recurring and and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list for(wrapBilling cbill : wrapRecords_NR){ if(cbill.selected == true) { selectedbill.add(cbill.bill); selListId.add(cbill.bill.Id); } } for(wrapBilling cbill: wrapRecords_RecVar){ if(cbill.selected == true) { selectedbill.add(cbill.bill); selListId.add(cbill.bill.Id); } } // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc if(selectedbill != null){ System.debug('These are the selected billing records...'); for(Billing__c bill: selectedbill) { system.debug(bill); system.debug('selListId: '+selListId); } if(sendMail()){ for(billing__c bill2Upd : [Select Id,Notification_to_Invoice__c from billing__c where Id in : selListId]){ bill2Upd.notification_to_Invoice__c = true ; system.debug('bill2Upd: ' + bill2Upd); update bill2Upd; } } } // wrapRecords_NR = null; // we need this line if we performed a write operation because getContacts gets a fresh list now selectedbill.clear(); return null; }
- the command button submits the form and executes the processselected action method
- the action support submits the form, but as it doesn't define an action attribute it simply updates the state of the controller and refreshes the page
Given what you are seeing, it sounds like the action support is the last to fire, which kills the command button postback processing and simply refreshes the page, thus your processselected method is never executed to generate the new list of contacts.Instead of embeddeding an actionsupport, just use the commandbutton and specific a rerender attribute:
(I've also removed the immediate="false" attribute, as that is the default behaviour.