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
Joe B.ax302Joe B.ax302 

rerender not rerendering :)

Ok, so here is my code.

Page:

Code:
<apex:page standardController="Task" extensions="timeTrackingExtension" tabStyle="Task">
    <apex:form >
        
        <apex:detail />
        
        <apex:Pageblock title="Time entry">
            <apex:inputText value="{!time}" id="time" />
            <apex:inputText value="{!duration}" id="duration" />
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" style="margin-top: 15px" action="{!create}" rerender="detail,ttrecords,resultPanel" status="saveStatus" />
            </apex:pageBlockButtons>
        </apex:Pageblock>

        <apex:actionStatus id="saveStatus" startText="Creating new time tracking record..." stopText="" />

        <apex:Pageblock title="Time Tracking History">
            <apex:outputPanel id="detail">
            <apex:pageBlockTable value="{!timeTrackingRecords}" var="tt" id="ttrecords">
                <apex:column value="{!tt.Name}" />
                <apex:column value="{!tt.Owner__c}" />
                <apex:column value="{!tt.Time__c}" />
                <apex:column value="{!tt.Duration__c}" />
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:Pageblock>
        
        <apex:pageBlock title="Fetched Data">
            <apex:outputPanel id="resultPanel" layout="block">
                Result: {!timeTrackingRecords}"
            </apex:outputPanel>
        </apex:pageBlock>


    </apex:form>
</apex:page>

 
Controller:

Code:
public class timeTrackingExtension {

    private final Task task;
    Integer ttime = 0;
    String duration;
    List<TimeTracking__c> timeTrackingRecords;
    
    // The extension constructor initializes the private member
    // variable task by using the getRecord method from the standard
    // controller.
    public timeTrackingExtension(ApexPages.StandardController stdController) {
        this.task = (Task)stdController.getRecord();
    }
    
    // Return TimeTracking__c records for the task specified in the query string
    // i.e.
    // —id=00TT0000008kYBKMA2
    public List<TimeTracking__c> getTimeTrackingRecords() {
        
        if(timeTrackingRecords == null) timeTrackingRecords = [Select t.Duration__c, t.Id, t.Name, t.Owner__c, t.TaskId__c, t.Time__c from TimeTracking__c t
            where t.TaskId__c = :ApexPages.currentPage().getParameters().get('id')];
        
        for(TimeTracking__c tt : timeTrackingRecords) {
            System.debug(tt.Name);
        }
        
        return timeTrackingRecords;
        
    }
    
    public Integer getTime() {
        return ttime;
    }
    
    public void setTime(Integer i) {
        ttime = i;
    }
    
    public String getDuration() {
        return duration;
    }
    
    public void setDuration(String s) {
        duration = s;
    }
    
    // Creates a TimeTracking__c record
    public PageReference create() {
        TimeTracking__c newTimeTrackingRecord = new TimeTracking__c();
        newTimeTrackingRecord.TaskId__c = ApexPages.currentPage().getParameters().get('id');
        newTimeTrackingRecord.Owner__c = UserInfo.getUserId();
        newTimeTrackingRecord.Time__c = ttime;
        newTimeTrackingRecord.Duration__c = duration;
        insert newTimeTrackingRecord;
        return null;
    }

}

 
For some reason or another the pageBlockTable and outputPanel are not being updated after I create a new record.  Anyone have any ideas as to why?  My initial thought is that I need to do my insert differently...

Other options are welcome :)  Thanks!@
Joe B.ax302Joe B.ax302
This did not seem to help either:

Page:

Code:
<apex:page standardController="Task" extensions="timeTrackingExtension" tabStyle="Task">
    <apex:form >
        
        <apex:detail />
        
        <apex:Pageblock title="Time entry">
            <apex:inputText value="{!time}" id="time" />
            <apex:inputText value="{!duration}" id="duration" />
            <br /><br />
            <apex:inputField value="{!timeTrackingRecord.Time__c}" id="time2" />
            <apex:inputField value="{!timeTrackingRecord.Duration__c}" id="duration2" />
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" style="margin-top: 15px" action="{!create}" rerender="detail,ttrecords,resultPanel" status="saveStatus" />
                <apex:commandButton value="Save2" style="margin-top: 15px" action="{!createV2}" rerender="detail,ttrecords,resultPanel" status="saveStatus" />
            </apex:pageBlockButtons>
        </apex:Pageblock>

        <apex:actionStatus id="saveStatus" startText="Creating new time tracking record..." stopText="" />

        <apex:Pageblock title="Time Tracking History">
            <apex:outputPanel id="detail">
            <apex:pageBlockTable value="{!timeTrackingRecords}" var="tt" id="ttrecords">
                <apex:column value="{!tt.Name}" />
                <apex:column value="{!tt.Owner__c}" />
                <apex:column value="{!tt.Time__c}" />
                <apex:column value="{!tt.Duration__c}" />
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:Pageblock>
        
        <apex:pageBlock title="Fetched Data">
            <apex:outputPanel id="resultPanel" layout="block">
                Result: {!timeTrackingRecords}"
            </apex:outputPanel>
        </apex:pageBlock>


    </apex:form>
</apex:page>

 Controller:

Code:
public class timeTrackingExtension {

    private final Task task;
    Integer ttime = 0;
    String duration;
    TimeTracking__c timeTrackingRecord;
    List<TimeTracking__c> timeTrackingRecords;
    
    // The extension constructor initializes the private member
    // variable task by using the getRecord method from the standard
    // controller.
    public timeTrackingExtension(ApexPages.StandardController stdController) {
        this.task = (Task)stdController.getRecord();
        this.timeTrackingRecord = new TimeTracking__c();
    }
    
    // Return TimeTracking__c records for the task specified in the query string
    // i.e.
    // —id=00TT0000008kYBKMA2
    public List<TimeTracking__c> getTimeTrackingRecords() {
        
        if(timeTrackingRecords == null) timeTrackingRecords = [Select t.Duration__c, t.Id, t.Name, t.Owner__c, t.TaskId__c, t.Time__c from TimeTracking__c t
            where t.TaskId__c = :ApexPages.currentPage().getParameters().get('id')];
        
        for(TimeTracking__c tt : timeTrackingRecords) {
            System.debug(tt.Name);
        }
        
        return timeTrackingRecords;
        
    }
    
    public TimeTracking__c getTimeTrackingRecord() {
        return timeTrackingRecord;
    }
    
    public void setTimeTrackingRecord(TimeTracking__c t) {
        timeTrackingRecord = t;
    }
    
    public Integer getTime() {
        return ttime;
    }
    
    public void setTime(Integer i) {
        ttime = i;
    }
    
    public String getDuration() {
        return duration;
    }
    
    public void setDuration(String s) {
        duration = s;
    }
    
    // Creates a TimeTracking__c record
    public PageReference create() {
        TimeTracking__c newTimeTrackingRecord = new TimeTracking__c();
        newTimeTrackingRecord.TaskId__c = ApexPages.currentPage().getParameters().get('id');
        newTimeTrackingRecord.Owner__c = UserInfo.getUserId();
        newTimeTrackingRecord.Time__c = ttime;
        newTimeTrackingRecord.Duration__c = duration;
        insert newTimeTrackingRecord;
        return null;
    }
    
    public PageReference createV2() {
        timeTrackingRecord.TaskId__c = ApexPages.currentPage().getParameters().get('id');
        timeTrackingRecord.Owner__c = UserInfo.getUserId();
        insert timeTrackingRecord;
        return null;
    }


}

 


mba75mba75

Hi Joel,

I have the same issue I workaround I change return null;


    // Creates a TimeTracking__c record
    public PageReference create() {
        TimeTracking__c newTimeTrackingRecord = new TimeTracking__c();
        newTimeTrackingRecord.TaskId__c = ApexPages.currentPage().getParameters().get('id');
        newTimeTrackingRecord.Owner__c = UserInfo.getUserId();
        newTimeTrackingRecord.Time__c = ttime;
        newTimeTrackingRecord.Duration__c = duration;
        insert newTimeTrackingRecord;
        return null;
    }

With the

PageReference pageRef = ApexPages.currentPage();

pageRef.setredirect(true);

return pageRef;

That refresh the all page and my pageblocktable but it is not an AJAX behaviour .

So If any body know how make the rerender working after inserting a record ?

Regards

 

 

Joe B.ax302Joe B.ax302
Thanks for the reply!!... although I need an AJAX enabled page; this is great for demonstrating the general look and feel of the visualforce page I'm creating.  Hopefully someone out there has found a solution to our issue.  Thanks again for your help!