+ Start a Discussion
siddarth rajsiddarth raj 

Rerender of repeat component not updating the whole table

Hi champs

I Have a page displays a repeat block of consignment and followingly its items. One consignment could have more than 1.

repeat tag placed inside the pageblock with the id for suppose "pb"

one command button inside this repeat does some action after completion of action wanted to rerender the block "pb"  

I am experiencing wierd behaviour on block rerender latest update values are appearing for only items but not for the consignment. If i refresh the whole page,
page loading with the latest values.


What wrong would be the reason for this behaviour.

Please can i be provided any suggestions 

James LoghryJames Loghry
If you could post your Visualforce markup, then perhaps we could help a bit better.

That being said, are your rerender and id tags both the same case?  E.g. rerender="pB" won't render an id of "pb".

Also, does the consignment loop reside outside of the pb pageblock?

Furthermore, is it possible that your consignment records aren't updated / requeried when the apex:commandButton is clicked?  You could determine this by looking at System.debug statements in the apex action you're calling.

Not much help, I know, but if we could see what you're trying to rerender (and perhaps the action that you're calling as well), we may be able to help more.
siddarth rajsiddarth raj
Hi James

As i said in post If i refresh the whole page seeing updated values for the consignment aswell. It mean action method involed from my commandclik doing its fuction properly...function method updating both consignment and its itmes properly checked them in debug statements.

By the way as you requested here I am with my VF page code
<apex:component controller="DeliverySchedulerComponentController" allowDML="true" id="delivSchComponent">
    <apex:attribute name="pageController"
    type="AbstractParentController"
        assignTo="{!parentController}"
        required="true"
        description="The controller for the page." id="delivSchAttribute" />
        
              <apex:pageBlock id="pb">
             <apex:pageBlockSection title="View Delivery Schedule" id="delivSchPageBlockSecion" showHeader="false">
               <apex:pageBlockSectionItem />
               <apex:pageBlockSectionItem />
               <apex:outputField value="{!wrapper.deliverySchedule.Year__c}" id="delivYear" styleClass="year"/>                 
               <apex:outputField value="{!wrapper.deliverySchedule.Month__c}" id="delivMonth" styleClass="month"/>                 
               <apex:pageBlockSectionItem />
               <apex:pageBlockSectionItem />
              </apex:pageBlockSection>
                            
               <apex:repeat value="{!wrapper.consignments}" var="consignment" id="delivConsignmentList">
                   <apex:pageBlockSection title="Consignment {!consignment.Position__c}" id="delivConsignment">
                     <apex:outputField value="{!consignment.Due__c}" id="delivDue" styleClass="due"/>
                     <apex:outputText value="{!consignment.Status__c}  {!consignment.ReceivedOn__c}"  id="delivStatus" styleClass="status" label="Status"/>    
                     <apex:outputField value="{!consignment.Delivery_Location__c}" id="delivLoc" styleClass="location" label="Location"/>      
                     <apex:outputText value="{!consignment.Instructions__c}" id="delivInstructions" styleClass="instructions" />
                   </apex:pageBlockSection>
                    
                   <apex:pageBlockTable value="{!wrapper.items[consignment.Position__c]}" var="item" columnsWidth="10%,25%,20% 20% 25%" styleClass="consignmentItems">
                       <apex:column value="{!item.Product__r.ProductCode}" headerValue="Product Code" id="delivCode" styleClass="code"/>
                       <apex:column value="{!item.Product__r.name}" headerValue="Product Name" id="delivProd" styleClass="name"/>
                       <apex:column value="{!item.Quantity__c}" headerValue="Quantity" styleClass="quantity"/>
                       <apex:column headerValue="Delivered" >
                            <apex:inputText value="{!item.Delivered_Quantity__c}" id="consitmReceived" ></apex:inputText>
                             </apex:column>
                       <apex:column headerValue="Accepted" >
                            <apex:inputText value="{!item.Quantity__c}" id="consitmAccepted"  ></apex:inputText>
                       </apex:column>
                   </apex:pageBlockTable>
                       <apex:commandButton value="Receive Delivery" reRender="pb" action="{!acknowledgeDelivery}"  id="deliReceived" disabled="{!consignment.Status__c=='Goods Receive'}" styleClass="goodsReceived">
                           <apex:param name="gotConsignement" value="{!consignment.Id}" assignTo="{!consId}" />
                           <apex:param name="consignmentItemPos" value="{!consignment.Position__c}" assignTo="{!consItemPos}" />
                       </apex:commandButton>
               </apex:repeat>
                   </apex:pageBlock>
 
           <apex:pageMessage summary="Orders cannot be SUBMITTED with the Errors. Please fix the Errors for SUBMIT process." severity="Error" strength="4" rendered="{!hasErrorMessages}" id="DeliveryMessageTwo" />
      
</apex:component>


Would be greatful for the help
Prem_PalPrem_Pal
Could you also post your controller please?
siddarth rajsiddarth raj
Here is controller

public  class DeliverySchedulerComponentController extends AbstractComponentController {

    public DeliveryScheduleWrapper wrapper           { get;set;}
    public DeliveryScheduleHelper deliveryHelper     { get;set;}
    public Delivery_Schedule__c delivery_schedule   { get;set;}
    public String consId{get;set;}
    public boolean manageDeliveryReceivedButton {get;set;} 
    public Integer consItemPos{get;set;}
    public String prdFamily;
      
  public boolean hasErrorMessages
  {
    get
    {
        return Apexpages.hasMessages(ApexPages.Severity.Error);
    }
  }
    public DeliverySchedulerComponentController () {
        initValues();       
    }
   
    private void initValues()
    {    
        if(modeOfScreen!=null && modeOfScreen!=NEW_MODE){
           
   setValuesFromParentController();
           
        }
        modeOfScreen = NEW_MODE;
        wrapper = new DeliveryScheduleWrapper();
               
        delivery_schedule = new Delivery_Schedule__c();

        //VG - Modified to make OrderType dynamically selected
     String RecType=ApexPages.currentPage().getParameters().get('RecordType');
     System.debug('Record type from Scheduler:***'+ProductsAndOrdersMap.getInstance().getProductfamilyByRTId(RecType));
      prdFamily=ProductsAndOrdersMap.getInstance().getProductfamilyByRTId(RecType);
        deliveryHelper = new DeliveryScheduleHelper(prdFamily);
        wrapper = deliveryHelper.create(delivery_schedule, prdFamily);
             
       
    }
   
    public override boolean save() {
        return deliveryHelper.save(wrapper);
    }
   
   public PageReference acknowledgeDelivery(){
       Savepoint sp = Database.setSavepoint();
       try{
          // System.debug('Consignment ID triggerd***'+consId);
           Map<Id, ConsignmentItem__c> cPageItems = new Map<Id, ConsignmentItem__c>(wrapper.items.get(consItemPos));
           List<ConsignmentItem__c> itemsExist= [select id, Delivered_Quantity__c from ConsignmentItem__c where Consignment__c=:consId];
           System.debug('Size of the list:***'+itemsExist.size());
           for(ConsignmentItem__c listItem:itemsExist){
               System.debug('Entered Values**:'+cPageItems.get(listItem.id).Delivered_Quantity__c);
              listItem.Delivered_Quantity__c= cPageItems.get(listItem.id).Delivered_Quantity__c;       
           }
          
           Consignment__c receivedConsignment = [select due__c, Instructions__C, Delivery_Location__c,status__c,ReceivedOn__c from Consignment__c where id=:consId];
           receivedConsignment.status__c=FixedValues.consignmentDelStatus;
           receivedConsignment.ReceivedOn__c=System.now();
           update receivedConsignment;
           update itemsExist;
           if(Debug.Status){
            System.debug('Delivery acknowledged'+receivedConsignment);
           }
          
            //return pageRef;
       }catch(Exception e){
           if(Debug.Status){
               System.debug('Update receive Delivery failed');
           }
           ApexPages.addMessages(e);
            Database.rollback(sp);
       }
       //wrapper = deliveryHelper.load(wrapper.deliverySchedule);
      return null;
      
   }
        
          
      
    public override boolean amend()
    {
        return (deliveryHelper.amend(wrapper));
    }
   
    public  AbstractParentController parentController   {
        get;
        set
        {
         if(value!=null)
            {
                parentController = value;
                setValuesFromParentController();
            }
        }}
    private void setValuesFromParentController()
    {  
     parentController.childComponentController = this;
     manageDeliveryReceivedButton = false;
    
     if((parentController.modeOfScreen.equalsIgnoreCase(VIEW_MODE)||parentController.modeOfScreen.equalsIgnoreCase(EDIT_MODE))&& parentController instanceof OrderFormExistOrderController)
        {
           OrderFormExistOrderController pController = (OrderFormExistOrderController) parentController;          
           ID orderId = pController.ordid;
           if(parentController.wrapper!=null)
           {
             wrapper = parentController.wrapper;
           }
           else {
             delivery_schedule = [SELECT ID, NAME,Account__c,Month__c,Region__c,Year__c FROM Delivery_Schedule__c where Order__c =:orderId ];
                wrapper = deliveryHelper.load(delivery_schedule);
           }
           displayErrorAndWarningMessages();
        }
       
       
        if(parentController.modeOfScreen.equalsIgnoreCase(VIEW_MODE)&& parentController instanceof ViewDeliveryScheduleExtension)
        {
            manageDeliveryReceivedButton = true;
             if(UserHelper.isNewEnergySupplierProfile() && delivery_schedule.Order__r.status==Fixedvalues.dccApprovedStatus){
              manageDeliveryReceivedButton = true;
         }
           ViewDeliveryScheduleExtension pController = (ViewDeliveryScheduleExtension) parentController;          
          wrapper = pController.wrapper;
         
        }
       
        if(parentController.modeOfScreen.equalsIgnoreCase(EDIT_MODE) && parentController instanceof EditDeliveryScheduleExtension)
        {
           //manageDeliveryReceivedButton = true;
          EditDeliveryScheduleExtension editDelExtn = (EditDeliveryScheduleExtension) parentController;
          wrapper = editDelExtn.wrapper;
        }
       
       
    }
    
   private void displayErrorAndWarningMessages()
   { 
   
        List<Apexpages.Message> messageList = new List<Apexpages.Message>();
       
        OrderFormControllerErrorHandler errorHandler = new OrderFormControllerErrorHandler(parentController,messageList);  
        errorHandler.processErrorAndWarningMessages();
        for(ApexPages.Message errMessage : messageList)
        {
            Apexpages.addMessage(errMessage);
        }
      
    }
   
   
}
Prem_PalPrem_Pal
Why is this line commented in acknowledgeDelivery method

//wrapper = deliveryHelper.load(wrapper.deliverySchedule);

Could you please uncomment it and try ?


siddarth rajsiddarth raj
tried...anyway it shouldn't be the problem...Actually on that acknowledgeDelivery action we are update 2 
1) consignemnt with the time
2) its items

After completion of it page loading latest values of consignment items...but not consignment with new status time..wierd behaviour.... Absolutelly both updating that i can see from debug statements and aslo whole page refresh or reload.

Something worg or something weird behaviour from salesforce troubling me for last 4 days. I have tried all my options. 

Would greatful if anyone think of any possibilities please share me..