You need to sign in to do that
Don't have an account?
PageBlockTable row values dissapear after rerender
Hello,
Looking for help solving a simple issue that will most likely be a quick fix but yet I've spent too much time trying to crack it. The issue is that I have a pageblocktable with OpportunityLineItems, these can have their fields updated such as Qty and Discount. on the Qty and Discount field's onblur event I perform an upsert of the OppLine so that the server can calculate the TotalPrice and other relevant fields. Once the save is done, I requery for the record to show the latest updated values from the server, BUT even though in the debug log I see that the record got updated, when I rerender the field (even tried rerendering the entire table) the value simply disappears as if by "magic".
How can I get the row rerendered with the new values in the record??? Please assist! Below is code for controller and VF page where the issue seems to be happening:
VF page table: (NOTE: some fields that are static and do not get updated have been removed to downsize post length)
<apex:outputPanel id="tablePnl"> <apex:pageblockTable value="{!OLIs}" var="OLI" id="OLIList" > <apex:column id="DelCol"> {!OLI.Id} -- {!OLI.TotalPrice} <apex:commandButton value="Delete" action="{!del}" rerender="tablePnl,detailPanel"> <apex:param name="delname" value="{!OLI.id}" assignTo="{!currOLIid}"/> </apex:commandButton> </apex:column> <apex:column headerValue="Quantity"> <apex:inputField value="{!OLI.Quantity}" id="fQTY" required="{!OLI.PriceBookEntry.Product2.Name != null}" > <apex:actionSupport event="onblur" rerender="tablePnl,fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!saveOLI}" disabled="{!(OLI.Quantity == null || OLI.Quantity <= 0) || (OLI.UnitPrice == null || OLI.UnitPrice <= 0)}" > <apex:param name="currOLIQty" value="{!OLI.Id}" assignTo="{!currOLIid}"/> </apex:actionSupport> </apex:inputField> </apex:column> <apex:column headerValue="Unit Cost" > <apex:inputField value="{!OLI.Unit_Cost__c}" id="fUnitCost"/> </apex:column> <apex:column headerValue="Sales Price ex VAT""> <apex:inputField value="{!OLI.UnitPrice}"/> </apex:column> <apex:column headerValue="Line Disc Pct."> <apex:inputField value="{!OLI.Discount}" id="fDiscPct"> <apex:actionSupport event="onblur" rerender="fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!saveOLI}" disabled="{!(OLI.Quantity == null || OLI.Quantity <= 0) || (OLI.UnitPrice == null || OLI.UnitPrice <= 0)}" > <apex:param name="currOLIQty" value="{!OLI.Id}" assignTo="{!currOLIid}"/> </apex:actionSupport> </apex:inputField> </apex:column> <apex:column headerValue="Total Price"> <apex:outputField value="{!OLI.TotalPrice}" id="fTotalPrice" /> </apex:column> </apex:pageBlockTable> </apex:outputPanel>
And this is the code in the controller that performs the saveOLI action (saving the record):
public PageReference saveOLI() { system.debug('###currOLI: ' + currOLI); currOLI.TotalPrice = null; try{ upsert currOLI; currOLI = loadOLI(currOLI); for(OpportunityLineItem o: OLIs) { if(o.id == currOLI.id) { o = currOLI; system.debug('###After saveOLI OLIs(o) from currOLI: ' + o); } } }catch(Exception e) { ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error saving Opportunity Product: ' + e.getMessage()); ApexPages.addMessage(myMsg); } return null; }
Hi
change render property, You need to write this render = "tablePnl" in the both actionsupport tag,
invoke that function getOLIs() which was a list function to populate pageblock table data, inside saveOLI() method.
And let me know , If it works or not,
If this post answers your question , please mark it as solutions so that It can be further referred .
Thanks
All Answers
Hi
change render property, You need to write this render = "tablePnl" in the both actionsupport tag,
invoke that function getOLIs() which was a list function to populate pageblock table data, inside saveOLI() method.
And let me know , If it works or not,
If this post answers your question , please mark it as solutions so that It can be further referred .
Thanks
Hi
I have the same problem, I am displaying products information in a pageblock table with a few input fields and a check box. On save I am performaing a check where if checkbox ix checked, quantity field must no be 0 which is default value.
if(prod.checked == true) {
if(prod.quantity ==0){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please Enter Quantity for the Product Selected!!') );
return null; ----> This return null statement is causing the problem , though I want to be on the same page I wan tto retain the values inputted by user
}
Can you please share your code or let me know how I can retain the values entered by user and the validation done.
Thanks
Sent from my iPhone 5