Newbie FetchSpecification
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.