function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
guyr1981guyr1981 

refresh a dataTable

Hi,

 

I have a few seelct lists that the user selects from and then press a commandButton that calls my API that save a list of objects in the DB.

On the bottom part of the screen I have a dataTable that presents all the object instances on the list that was just built.

 

The problem is: The dataTable doesn't refresh, I can change the selections and press go again and the DB changes, but my table that was already built and presented on the screen won't refresh.

 

I tried rebuilding it by using reRended on the action botton, but it didn't work (also tried wrapping the dataTable with outputPannel and tried to use it in the reRender, but it does nothing to the table, any suggestions?

 

Here is the relavent sections of the code:

 

....

....

....

<apex:commandButton action="{!refresh}" value="Go"  reRender="ThePageBlockWrapper"/>

 

 

<apex:outputPanel id="ThePageBlockWrapper">

      <apex:pageBlock title="Planing Table" id="thePageBlock" mode="edit">

          <apex:dataTable value="{!acc}" id="outputTable" var="pitem" columns="10" cellPadding="6">

          <apex:column headerValue="Account" >

          <apex:outputText value="{!pitem.name}" /> 

          </apex:column>

....
....
....

 

 

Thanks,

Guy

 

 

 

bob_buzzardbob_buzzard

I can't see anything obviously wrong with the page - the outputpanel should refresh when your action method is executed.

 

In my experience, this usually means that while I've written the changes to the database, I haven't rebuilt my cached list of data in the controller, so the table is refreshing but the data hasn't changed. 

 

If its not that, can you post the appropriate parts of your controller so that we can see exactly what happens when the refresh method is called.

guyr1981guyr1981

Hi,

 

This is not the case, unless the reRender is being called befor the refresh.

 

The refresh deletes all the records of my object which should be displayed in the dataTable and then inserts back all the objects to the DB (which will be different because I make changes in the Account__c, Corporate__c and Company__c before pressing the go button).

 

The other thing is:

After using the "go" Button ("refresh") the dataTable doesn't change, but, if I press the tab again and the page refreshes the dataTable would look different (as expected).

 

This is my controller code for refresh:

 

public PageReference refresh() {
        for (Table_Account__c delAcct: [select name, id from Table_Account__c])
                delete delAcct;
        for (Account__c accs: [select name, id, Corporate__c, Company__c from Account__c WHERE
             Corporate__c =: corporate AND Company__c =:company]) {
             this.acct = new Table_Account__c();
             System.debug(Logginglevel.DEBUG, 'this.acct = new Table_Account__c()');
             this.acct.name = 'test'+ accs.name;
             this.acct.account_name__c = accs.name;
             this.acct.test1__c = 111;
             this.acct.test2__c = 222;
             this.acct.test3__c = 0;
             System.debug(Logginglevel.DEBUG, 'before this.acct_list.add(acct)');
             insert (this.acct);
        }
        return null;
    }

also, this is my page defenition (if relevant):

 

<apex:page standardStylesheets="false" sidebar="false" StandardController="table_account__c" Extensions="MyController" tabStyle="Account" recordSetVar="acc">

 

I would like to resolve it in a way that only recreates the dataTable, but if you have no suggestion I would be happy if you tell me how to refresh the whole page.

 

In any case,

Thanks, for the time and effort trying to help me,

Guy

 

 

bob_buzzardbob_buzzard

It looks to me that the problem here is that while you are updating the records in the database, the acc variable from the parent standard set controller is not being updated.  I suggest you try repopulating that prior to returning from your refresh action method.

 

 

guyr1981guyr1981

Hi,

 

I thought that the recordSetVar="acc" just sets "acc" to be a refernce name for the standard record set variables on the DB and thought that updating the DB updates what acc is pointing to.

 

Anyway, how can I update the "acc" variable? 

 

Thanks,

Guy