• 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
Newbie FetchSpecification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie FetchSpecification


  • Subject: Newbie FetchSpecification
  • From: Serge Smadja <email@hidden>
  • Date: Fri, 14 Mar 2003 21:29:08 +0100

Hi

I've written my first WO program. It fetches one entity called "Site"
from a database based on parameters passed from a WOForm. The trouble
is when a SITE column value is modified in the database ie through a
DirectToWeb app, the page doesn't reflect the changes as if the
database was queried only once. What's happening ? What should I do to
make the Db fetch every time a changes occurs.

the lookupSite method is called upon a click on the form submit button.

Thanks

Here is my code :

import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;

public class Main extends WOComponent {
     public String siteToFind;
     public boolean noResults;
     public boolean foundResults;
     public Site site;

     /** @TypeInfo java.lang.String */
     public NSArray siteList;
     public String secteurToFind;

     public Main(WOContext context) {
         super(context);
     }

     public WOComponent lookupSite()
     {
         String siteToFindString = "*";
         if (siteToFind != null) {
             siteToFindString = siteToFind + "*";
         }
         String secteurToFindString = "*";
         if (secteurToFind != null) {
             secteurToFindString = secteurToFind + "*";
         }
         NSArray bindings = new NSArray(new Object[] {
             siteToFindString, secteurToFindString
         });

         EOQualifier qualifier =
EOQualifier.qualifierWithQualifierFormat("nomSite like %@ and
naf700Reference.codeNaf700 like %@", bindings);

         EOFetchSpecification fetchSpec = new
EOFetchSpecification("Site", qualifier, null);
         EOEditingContext myEditingContext =
this.session().defaultEditingContext();

         siteList =
myEditingContext.objectsWithFetchSpecification(fetchSpec);

         if (siteList.count() == 0) {
             noResults = true;
             foundResults = false;
         } else {
             noResults = false;
             foundResults = true;
         }
         return null;
     }

     public SiteDG showDetails()
     {

         SiteDG nextPage = (SiteDG)pageWithName("SiteDG");

         // Initialize your component here
         nextPage.setTheSite(site);
         return nextPage;
     }

}
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Newbie FetchSpecification
      • From: Art Isbell <email@hidden>
  • Prev by Date: Re: Apache vars
  • Next by Date: ( J2EE == WebObjects )?
  • Previous by thread: Re: Apache vars
  • Next by thread: Re: Newbie FetchSpecification
  • Index(es):
    • Date
    • Thread