Re: db connect in session
Re: db connect in session
- Subject: Re: db connect in session
- From: Strausz Riccardo <email@hidden>
- Date: Mon, 11 Aug 2003 11:34:33 -0500
Are you using WODisplayGroups??
I think, they will make your life easer!
On sabado, agos 9, 2003, at 12:41 America/Mexico_City, Jeff Martirano
wrote:
My first reaction is "Wow, you are doing something really wrong!".
What I'm doing is very simple, and it's very likely that I am doing it
wrong, and making it more complicated than it needs to be. Your first
reaction is probably correct.
EOClassDescription code?!!? I've done some fairly advanced WO work
and
only twice have I needed to do anything with EOClassDescription. I'm
almost as puzzled about the redundant EOEditingContext code. Either
you
are really jumping in at the deep end or you're doing something wrong.
I
can see having some duplication of EOFetchSpecification code. These
can
also be placed on the eo objects or in the EOModel. Either is a
better
place than Session (if I understand what you are doing).
Perhaps you can post some code samples to demonstrate what sort of
code you
are concerned with.
My question was probably misleading, I'm definitely not doing anything
advanced.
in Session.java:
public EOEditingContext categoryEditingContext;
public EOClassDescription categoryClassDescription;
public EOFetchSpecification categoryFetchSpec;
public EOEnterpriseObject categoryItem;
public NSMutableArray categoryList;
protected EOEnterpriseObject category;
public Session() {
super();
categoryEditingContext = defaultEditingContext();
categoryFetchSpec = new EOFetchSpecification("Category", null,
null);
categoryList = new
NSMutableArray(categoryEditingContext.objectsWithFetchSpecification(cat
e
goryFetchSpec));
categoryClassDescription =
EOClassDescription.classDescriptionForEntityName("Category");
category = new EOGenericRecord(categoryClassDescription);
}
Then from WOBuilder I can use WORepitition to list the results, etc.
for different components without having to type all of the above info
into each component's java file. If I want to create new entries I put
the following code in my component's java file for when they click the
submit button:
public categoryList submitCategoryEntry()
{
Session session = (Session)session();
categoryList nextPage =
(categoryList)pageWithName("categoryList");
session.categoryList.addObject(session.category);
session.categoryEditingContext.insertObject(session.category);
session.category = new
EOGenericRecord(session.categoryClassDescription);
session.categoryEditingContext.saveChanges();
return nextPage;
}
It all seems to be working fine, but I understand that there is also
very likely an easier way of accomplishing this. This is all code that
I've modified from Apple examples (although they didn't include it in
Session.java, but rather the component's java file).
Insight is definitely appreciated.
Jeff
Chuck
At 08:20 AM 09/08/2003 -0700, Jeff Martirano wrote:
I'm new to WO, and I'm trying to figure out the best application
design
patterns. I've been testing things by making some apps, and realized
I
was using a lot of redundant code for EOEditingContext,
EOClassDescription, and EOFetchSpecification declarations and of
course
actually setting those properties. I put the declarations and set the
variables in the Session.java and it worked, but does it make sense
to
do so?
I can see that I'm going to have a lot of basic application design
questions as I'm learning WO, is there a resource to read up on some
of
this? The books seem to just have tutorials on how to get certain
jobs
done, not necessarily putting the big picture in focus.
_______________________________________________
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.
--
Chuck Hill email@hidden
Global Village Consulting Inc.
http://www.global-village.net
_______________________________________________
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.
_______________________________________________
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.