You need to sign in to do that
Don't have an account?
Field not rerendering in pageblocktable
Hello,
I havea pageblocktable updated from the controller where I list order items. One of the fields is the product lookup (custom made, not the standarad one from SF). I point the inputText of the lookup to a productID__r.Name field of the product and also update some other fields in teh table when teh user changes the product reference. Alont htese rerenders should also be the product name field, but only the other fields are rerendering (description, and price fields). Can anyone tell me where I am coding this wrong???
debugging behind the scenes show taht tthe values are correct so the rerendering should be showing the correct values, so therefore I think the problem is in the actual rerendering of the field.
VF page:
<apex:pageblock title="Sales Order Items" tabStyle="SCRB_SalesOrder__c" id="SOIpgblk" >
<div style="text-align: center;"> <apex:messages style="font-weight: bold; color:red;" /></div>
<apex:pageBlockButtons location="top" >
<apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl" disabled="{!NOT(SOsaved)}" id="btnAddSOI" />
</apex:pageBlockButtons>
<apex:actionRegion id="prodUpdate" renderRegionOnly="false">
<apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel,tablePnl">
<apex:param id="prodId" value="" name="prodId"/>
</apex:actionFunction>
</apex:actionRegion>
<apex:outputPanel id="tablePnl">
<apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
<apex:column headerValue="Line type" id="ltcol">
<apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
<apex:inputField value="{!SOI.Line_Type__c}" id="fLineType" required="true" >
<apex:actionSupport event="onblur" reRender="detailPanel,currLineTypefld" action="{!loadSOIDs}" >
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
<apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Product" id="prodCol">
<apex:actionRegion id="prodRgn">
<apex:inputText value="{!SOI.ProductId__r.name}" id="fProd" onFocus="this.blur()" />
<apex:commandLink onclick="prodLookup(this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].options[this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].selectedIndex].value);" reRender="fProd">
<apex:image value="{!$Resource.lookupIcon}"/>
<apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Description">
<apex:actionRegion id="rgnDesc" renderRegionOnly="false" >
<apex:inputField value="{!SOI.Description__c}" id="fDescr" >
<apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
<apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
</apex:column>
REMOVED SOME COLUMNS TO SAVE SPACE
<apex:column headerValue="Profit" >
<apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>
</apex:column>
<apex:column headerValue="Total Price">
<apex:outputField value="{!SOI.TotalPrice__c}" id="fTotalPrice"/>
</apex:column>
<apex:column headerValue="Line Status" >
<apex:outputField value="{!SOI.Line_Status__c}" id="fLineStatus" />
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
Hello,
THANKS TO EVERYONE WHO PITCHED IN TO HELP ME SOLVE THE ISSUE. I finally solved the problem of the field not updating: see below the udpated controller code:
if(id == null ) { return null;}
loadCurrProd(id);
PriceBook2 pb = [SELECT Id,IsStandard,Name FROM Pricebook2 WHERE IsStandard = True Limit 1];
pbEntry = [SELECT Id,Pricebook2Id,Product2Id,ProductCode,UnitPrice FROM PricebookEntry WHERE Product2Id = :mProd.Id AND PriceBook2Id = :pb.id Limit 1];
system.debug('###CurrProd lookup: ' + mProd);
currSOI.ProductId__c = mProd.id;
system.debug('###currProd name: ' + currSOI.ProductId__r.Id + ' -- currSOI.ProdId: ' + currSOI.ProductId__c);
currSOI.SalesPrice__c = pbEntry.UnitPrice;
currSOI.Unit_Cost__c = mProd.Unit_Cost__c;
currSOI.Description__c = mProd.Description;
currSOI.Line_Discount_Amount__c= 0;
currSOI.Line_Discount_Pct__c = 0;
currSOI.TotalPrice__c = 0;
currSOI.Quantity__c = 0;
currSOI.Total_Price_bef_Disc__c = 0;
currSOI.Profit__c = 0;
currSOI.ProductID__r.Name = mProd.Name;
//UPSERT CURRSOI to update relationship field for product
upsert currSOI;
I added that line of code and now it works just fine. I guess you need to actually assign the value to it even though I already assigned the productId at the top. If anyone knows why this is so please let me know as that was the root of the issue!!
Best regards,¨
Mauricio
All Answers
I don't see 'detailPanel' id being set anywhere in the code. Is this intentional? Also, i'd put a space between the 2 comma seperated values.
So write it as:
reRender="detailPanel, tablePnl"
Hope this helps!
Hi thanks for your reply.
Yes its intentional, the detailPanel is another pageblock further below that is also affected by a product selection, it should have nothing to do with the problem at hand, I also tried adding a space in between the rerender list but to no luck. The field still does not rerender. Can it be something related to output panels, action regions or the likes?
Don't put the <apex:actionFunction> inside the <apex:actionRegion> but put the affected panel (that you want to refresh between the <apex:actionRegion> tags. Try this and let me know.
Hi,
I have done as you suggested and moved the <apexregion> tags around the tablePnl (the one that should be refreshed) but no changes. The field still does not refresh.
<apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel, tablePnl" immediate="true">
<apex:param id="prodId" value="" name="prodId"/>
</apex:actionFunction>
<apex:actionRegion id="prodUpdate" renderRegionOnly="false">
<apex:outputPanel id="tablePnl">
<apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
.......
</apex:pageBlockTable>
</apex:outputPanel>
</apex:actionRegion>
hmm...can you post the new reformatted code? Also, you are sure that there are exceptions thrown during this ajax request. Try using firebug, or chrome developer console to see if something is not right. Also, where is the javascript function doUpdateProdData() called?
- Anup
Hi,
I will add the VF page code in next post as it will not fit in this one.
Hello,
THANKS TO EVERYONE WHO PITCHED IN TO HELP ME SOLVE THE ISSUE. I finally solved the problem of the field not updating: see below the udpated controller code:
if(id == null ) { return null;}
loadCurrProd(id);
PriceBook2 pb = [SELECT Id,IsStandard,Name FROM Pricebook2 WHERE IsStandard = True Limit 1];
pbEntry = [SELECT Id,Pricebook2Id,Product2Id,ProductCode,UnitPrice FROM PricebookEntry WHERE Product2Id = :mProd.Id AND PriceBook2Id = :pb.id Limit 1];
system.debug('###CurrProd lookup: ' + mProd);
currSOI.ProductId__c = mProd.id;
system.debug('###currProd name: ' + currSOI.ProductId__r.Id + ' -- currSOI.ProdId: ' + currSOI.ProductId__c);
currSOI.SalesPrice__c = pbEntry.UnitPrice;
currSOI.Unit_Cost__c = mProd.Unit_Cost__c;
currSOI.Description__c = mProd.Description;
currSOI.Line_Discount_Amount__c= 0;
currSOI.Line_Discount_Pct__c = 0;
currSOI.TotalPrice__c = 0;
currSOI.Quantity__c = 0;
currSOI.Total_Price_bef_Disc__c = 0;
currSOI.Profit__c = 0;
currSOI.ProductID__r.Name = mProd.Name;
//UPSERT CURRSOI to update relationship field for product
upsert currSOI;
I added that line of code and now it works just fine. I guess you need to actually assign the value to it even though I already assigned the productId at the top. If anyone knows why this is so please let me know as that was the root of the issue!!
Best regards,¨
Mauricio
Well done. Glad to be of service, sir! Just realized that I had a brain fart earlier when I suggested moving the action region. For some reason i thought it would impact rerender, when it just demarcates the region for Ajax.