• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EO refresh question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EO refresh question


  • Subject: Re: EO refresh question
  • From: John Huss <email@hidden>
  • Date: Wed, 14 Sep 2011 10:18:18 -0500

I think you need to call setRefreshesRefetchedObjects(true) on the fetch specification.

John

On Wed, Sep 14, 2011 at 9:51 AM, Pascal Robert <email@hidden> wrote:
I have a question about EO refresh. I have a component where I show the list of running and completed jobs (reports) and since some jobs might be running, I want to use AjaxPing to refresh the page every 5 seconds so that users don't have to click on a link or button to refresh the page.

The list is built with:
  
  public NSArray<ReportTask> reportsForCurrentUser() {
    return ReportTask.fetchReportTasks(editingContext(), ReportTask.USER.eq(((Session)session()).user()), ReportTask.START_TIME.descs());
  }

The editing context have a 1 second timestamp:

  protected EOEditingContext editingContext() {
    if (_editingContext == null) {
      _editingContext = ERXEC.newEditingContext();
      _editingContext.setFetchTimestamp(1000);
    }
    return _editingContext;
  }

And I have a method, countOfRunningJobs, that fetch the list of currently running or pending jobs. I use that method to return the number of running jobs and use it as the "cacheKey" binding for AjaxPing.

  public int countOfRunningJobs() {
    EOQualifier qualifier = ReportTask.USER.eq(((Session)session()).user()).and(ReportTask.STATUS.notIn(new NSArray<ReportTaskStatus>(new ReportTaskStatus[] { ReportTaskStatus.COMPLETED, ReportTaskStatus.STOPPED } )));
    NSArray<ReportTask> runningTasks = ReportTask.fetchReportTasks(editingContext(), qualifier, null);
    for (ReportTask task: runningTasks) {
      editingContext().refreshObject(task);
      NSLog.out.appendln(task.status());
    }
    return ReportTask.fetchReportTasks(editingContext(), qualifier, null).count();
  }

That logic is ok, if I print the integer in the component, the value is ok (eg, if I have a running job, count is 1, when the job is completed, count is 0). But the "task" EO is NOT updated after the refresh, even if in the database, the status was changed to "COMPLETED", the NSLog call returns "RUNNING". I do see a SELECT being done to fetch the task details, so it look it's EOF who doesn't want to refresh the object, even if the timestamp is low.

What I'm doing wrong?



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >EO refresh question (From: Pascal Robert <email@hidden>)

  • Prev by Date: Re: How can I a additional rel tags to additionalCSSFiles function in components?
  • Next by Date: Re: Deploy as a servlet
  • Previous by thread: EO refresh question
  • Next by thread: Re: EO refresh question
  • Index(es):
    • Date
    • Thread