You need to sign in to do that
Don't have an account?
Joe B.ax302
rerender not rerendering :)
Ok, so here is my code.
Page:
Controller:
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!@
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>
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; } }
Other options are welcome :) Thanks!@
Page:
Controller:
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