Re: Sophisticated relationship help

2006-02-27 Thread Amedeo Mantica
remember that exists a WebObject elemment called "WOToManyRelationship" that display you a checkbox matrix for assigning relationships, and works fine.AmedeoOn 26/feb/06, at 08:10, Jim Wong wrote:Can seem to get the below logic to work in my app.need your help. thanks.I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. COMPANY- companyID (attribute)OPPORTUNITY- oppID (attribute)- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))OPPORTUNITY_CUSTOMER- oppID (attribute)- customerID (attribute)- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))The requirements of a form are:- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. - Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. how can i get the above done? how's the coding requirement be like?  Warmest Regards,Jim Wong[EMAIL PROTECTED] On 26 Feb 2006, at 12:59 AM, Mark Morris wrote:Yes, it is bound to WORepetition's "item".  WORepetition will put into it the current Object from the "list".  It can be any object. :-)Regards,MarkOn Feb 25, 2006, at 8:26 AM, Jim Wong wrote:thanks for reply.the currentCompany you specified can be any object right? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 25 Feb 2006, at 10:00 PM, Mark Morris wrote:Hi Jim,Sorry it took a little longer to get back with you.  I had gone to bed (and I see there's a big time difference between us).It will get called automatically when the form is submitted, by the WOCheckBox component, and it will pass in the current value of the checkbox (true for checked, false for unchecked).This is very handy, and you can make your checkboxes do and reflect just about anything you can think of!  :-)Regards,MarkOn Feb 25, 2006, at 2:54 AM, Jim Wong wrote:Hi Mark:1 question: when will the setCompanyIsInArray() ever be called? do i have to invoke this method somewhere? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 25 Feb 2006, at 3:39 PM, Mark Morris wrote:Hello Jim,You can use the "isChecked" binding to do this.For example, bind it to a method named "companyIsInArray".  Assume your WORepetition's "item" binding is set to "currentCompany", and the destination (mutable) array is called "companyArray".  Then write something like (warning, not debugged!):	public boolean companyIsInArray() {	   return companyArray.containsObject( currentCompany );	}	public void setCompanyIsInArray( boolean value ) {	   if( value && !companyIsInArray() ) {	      companyArray.addObject( currentCompany );	   }	   if( !value && companyIsInArray() ) {	      companyArray.removeObject( currentCompany );	   }	}This would do what you want.Regards,MarkOn Feb 24, 2006, at 11:34 PM, Jim Wong wrote: I want to display a list of objects from entity COMPANY. the list will be displayed using WORepetition. Each line will contain the companyName and a WOCheckBox. When "GO" button is clicked, I want to pass all the selections into a NSMutableArray. But I dunno how to code this. ANyone can help? Thanks.Jim___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/markm%40onpointsoftware.comThis email sent to [EMAIL PROTECTED]   ___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/amedeo%40macintossicati.comThis email sent to [EMAIL PROTECTED]  ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Re: Sophisticated relationship help

2006-02-26 Thread Art Isbell

On Feb 26, 2006, at 5:49 PM, David LeBer wrote:


On 26-Feb-06, at 10:33 PM, Jim Wong wrote:


can't seem to get it to work. I don't get it. There's still an error.
	   return anOpportunity.companies().containsObject 
( currentCompany );
this statement doesn't invoke. it returns a nullpointer exception.  
Why?



One of the items in that method chain is nulling out and it shouldn't.

You're going to have to break the line code apart and figure it out.


	Or run under the Java debugger, set a breakpoint at that statement,  
and examine the value of anOpportunity which seems likely to be the  
culprit.  If it's not null, its companies() relationship could be  
empty, but shouldn't be null.  containsObject() isn't documented to  
throw a null pointer exception if its argument is null, but the value  
of currentCompany should also be checked just in case.


	Finding out what's null when it shouldn't be probably won't be as  
difficult as figuring out why the object is null.  But you have to  
figure out what's null first.  Learning how to debug such common  
problems will save you lots of time because you will no longer depend  
on others to help you debug.


Aloha,
Art

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com


Re: Sophisticated relationship help

2006-02-26 Thread David LeBer


On 26-Feb-06, at 10:33 PM, Jim Wong wrote:


can't seem to get it to work. I don't get it. There's still an error.
	   return anOpportunity.companies().containsObject 
( currentCompany );
this statement doesn't invoke. it returns a nullpointer exception.  
Why?


Because something is null that shouldn't be?

Seriously,

One of the items in that method chain is nulling out and it shouldn't.

You're going to have to break the line code apart and figure it out.

--
;david

--
David LeBer
Codeferous Software
'co-defer-ous' adj. producing or containing code
site:   http://www.codeferous.com
blog: http://david.codeferous.com






smime.p7s
Description: S/MIME cryptographic signature
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Re: Sophisticated relationship help

2006-02-26 Thread Jim Wong
can't seem to get it to work. I don't get it. There's still an error. 	   return anOpportunity.companies().containsObject( currentCompany );this statement doesn't invoke. it returns a nullpointer exception. Why? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 27 Feb 2006, at 1:37 AM, Michael Warner wrote:An obvious situation in which flattened relationships are not appropriate is the one in which you have attributes that belong directly in the linking table (in this case, the OPPORTUNITY_COMPANY table).Sometimes you don't anticipate these attributes right away.   With experience you will learn to recognize situations in which it is obvious to you that the only attributes in the  join table will be the two primary keys from the other tables, in which case, flattening can be very convenient. Mike WarnerOn Feb 26, 2006, at 12:08 PM, Mark Morris wrote:Hello Jim,You'll be safest if you stick to using flattened relationships for many-to-many's, and for nothing else.I haven't used Art's method, but he says it'll create the flattened relationship for you, so just leave it at that.  Make sure the non-flattened relationships (the ones directly to and from OPPORTUNITY_CUSTOMER) are not exposed to the class (uncheck the diamond column in EOModeler, and make sure any java classes don't have methods calling those relationships directly).Finally, you can modify the code I sent earlier like this (and again, I haven't run or debugged this):	public boolean opportunityHasCompany() {	   return anOpportunity.companies().containsObject( currentCompany );	}	public void setOpportunityHasCompany( boolean value ) {	   if( value && !opportunityHasCompany() ) {	      anOpportunity.addObjectToBothSidesOfRelationshipWithKey( currentCompany, "companies" );	   }	   if( !value && opportunityHasCompany() ) {	      companyArray.removeObjectFromBothSidesOfRelationshipWithKey( currentCompany, "companies" );	   }	}Where "companies" is the flattened many-to-many from Opportunity to Company, anOpportunity is the Opportunity being modified, and currentCompany is the "item" in the WORepetition.Regards,MarkOn Feb 26, 2006, at 2:21 AM, Jim Wong wrote:thanks art. what's flattened relationships? i can't catch wat the WO tutorial is talking abt. when do i use flattened and when do i not use? any pros and cons? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 26 Feb 2006, at 4:10 PM, Art Isbell wrote:On Feb 25, 2006, at 9:10 PM, Jim Wong wrote:I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. COMPANY- companyID (attribute)OPPORTUNITY- oppID (attribute)- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))OPPORTUNITY_CUSTOMER- oppID (attribute)- customerID (attribute)- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))The requirements of a form are:- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. - Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. how can i get the above done? how's the coding requirement be like? 	EOModeler can build a valid many-to-many relationship between Company and Opportunity.  This is preferable to building these relationships manually because it's easy to make a mistake.  Click the Tools > Table Mode EOModeler menu.  Select the model name (the top node along the left edge of the EOModeler window).  In the right section of the window, select the Company and Opportunity entities.  Click the Property > Join in Many to Many menu item.  This will create Company.opportunities and Opportunity.companies to-many relationships that are flattened across the Opportunity_Company join entity.  Inspect the Opportunity_Company entity to make sure that it has the correct table name.  You may rename the Opportunity_Company entity to Opportunity_Customer and the Opportunity.companies relationship to Opportunity.customers if you prefer.	Then when the form is submitted, iterate through the selected companies adding each company to the Opportunity.customers relationship:	opportunity.addObjectToBothSidesOfRelationshipWithKey(selectedCompany, "customers");Then send a saveChanges() message to the editing context.  Your eomodel will guide EOF to automatically manage the Opportunity_Customer entity which you don't need to refer to in your code or even to generate a custom Java class for; just leave it an EOGenericRecord. Aloha, Art   ___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/jimwong%40thegnow.comThis email sent to [EMAIL PROTECTED]  ___Do not post admin requests to th

Re: Sophisticated relationship help

2006-02-26 Thread Jerry W. Walker
Hi, Jim,On Feb 26, 2006, at 3:21 AM, Jim Wong wrote:thanks art. what's flattened relationships? i can't catch wat the WO tutorial is talking abt. when do i use flattened and when do i not use? any pros and cons?A flattened relationship is a relationship whose definition in the EOModel is based on the definition of another relationship in such a way that you don't have to use the base relationship in your code.So, for your problem you have three entities in the following structure:    COMPANY <->> OPPORTUNITY_COMPANY <<-> OPPORTUNITYThis structure, however, is an artifact of relational databases and is the solution that they force on you when what you really want is this structure:   COMPANY <<->> OPPORTUNITYEven though this latter structure is perfectly acceptable in your object graph where a Company instance would have an NSArray attribute named opportunities whose elements each point to a related opportunity and where an Opportunity instance would have an NSArray attribute named companies whose elements each point to a related company, it simply can't be reflected in the relational database and still have the database be relational. Notice that in the object graph, then, there is no direct correspondence to the OPPORTUNITY_COMPANY table.So, EOModel lets you create a pseudo-relationship in each of COMPANY and OPPORTUNITY to represent the NSArrays that will be derived, and each of these pseudo-relationships is defined on the underlying real relationship (real in the sense that it's directly reflected in the relational model). Finally, the diamond in EOModeler that determines whether an EOEntity's attribute or relationship is reflected in the object graph as a class property is removed so that the "real" relationships are not reflected anywhere in the object graph, but are replaced by the "pseudo-relationships".This replacement in the EOModel and, as a consequence, in the class model of the "real" relationships by the "pseudo-relationships" is called flattening the relationships.From the EOModeler User Guide:A flattened attribute is a special kind of attribute that you effectively add from one entity to anotherby traversing a relationship. When you form a to-one relationship between two entities (such asPerson and PersonPhoto), you can add attributes from the destination table to the source table.Regarding their downsides and when they should be used, take a look at the EOModeler User Guide under flattened relationships and flattened attributes. You can find the guide at:   http://developer.apple.com/documentation/WebObjects/UsingEOModeler/Regards,Jerry Warmest Regards,Jim Wong[EMAIL PROTECTED] On 26 Feb 2006, at 4:10 PM, Art Isbell wrote:On Feb 25, 2006, at 9:10 PM, Jim Wong wrote:I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. COMPANY- companyID (attribute)OPPORTUNITY- oppID (attribute)- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))OPPORTUNITY_CUSTOMER- oppID (attribute)- customerID (attribute)- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))The requirements of a form are:- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. - Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. how can i get the above done? how's the coding requirement be like? 	EOModeler can build a valid many-to-many relationship between Company and Opportunity.  This is preferable to building these relationships manually because it's easy to make a mistake.  Click the Tools > Table Mode EOModeler menu.  Select the model name (the top node along the left edge of the EOModeler window).  In the right section of the window, select the Company and Opportunity entities.  Click the Property > Join in Many to Many menu item.  This will create Company.opportunities and Opportunity.companies to-many relationships that are flattened across the Opportunity_Company join entity.  Inspect the Opportunity_Company entity to make sure that it has the correct table name.  You may rename the Opportunity_Company entity to Opportunity_Customer and the Opportunity.companies relationship to Opportunity.customers if you prefer.	Then when the form is submitted, iterate through the selected companies adding each company to the Opportunity.customers relationship:	opportunity.addObjectToBothSidesOfRelationshipWithKey(selectedCompany, "customers");Then send a saveChanges() message to the editing context.  Your eomodel will guide EOF to automatically manage the Opportunity_Customer entity which you don't need to refer to in your code or even to generate a custom Java class for; just leave it an EOGenericRecord. Aloha, Art   ___Do not post admin requests to the list. They will be ignored.We

Re: Sophisticated relationship help

2006-02-26 Thread Michael Warner
An obvious situation in which flattened relationships are not appropriate is the one in which you have attributes that belong directly in the linking table (in this case, the OPPORTUNITY_COMPANY table).Sometimes you don't anticipate these attributes right away.   With experience you will learn to recognize situations in which it is obvious to you that the only attributes in the  join table will be the two primary keys from the other tables, in which case, flattening can be very convenient. Mike WarnerOn Feb 26, 2006, at 12:08 PM, Mark Morris wrote:Hello Jim,You'll be safest if you stick to using flattened relationships for many-to-many's, and for nothing else.I haven't used Art's method, but he says it'll create the flattened relationship for you, so just leave it at that.  Make sure the non-flattened relationships (the ones directly to and from OPPORTUNITY_CUSTOMER) are not exposed to the class (uncheck the diamond column in EOModeler, and make sure any java classes don't have methods calling those relationships directly).Finally, you can modify the code I sent earlier like this (and again, I haven't run or debugged this):	public boolean opportunityHasCompany() {	   return anOpportunity.companies().containsObject( currentCompany );	}	public void setOpportunityHasCompany( boolean value ) {	   if( value && !opportunityHasCompany() ) {	      anOpportunity.addObjectToBothSidesOfRelationshipWithKey( currentCompany, "companies" );	   }	   if( !value && opportunityHasCompany() ) {	      companyArray.removeObjectFromBothSidesOfRelationshipWithKey( currentCompany, "companies" );	   }	}Where "companies" is the flattened many-to-many from Opportunity to Company, anOpportunity is the Opportunity being modified, and currentCompany is the "item" in the WORepetition.Regards,MarkOn Feb 26, 2006, at 2:21 AM, Jim Wong wrote:thanks art. what's flattened relationships? i can't catch wat the WO tutorial is talking abt. when do i use flattened and when do i not use? any pros and cons? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 26 Feb 2006, at 4:10 PM, Art Isbell wrote:On Feb 25, 2006, at 9:10 PM, Jim Wong wrote:I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. COMPANY- companyID (attribute)OPPORTUNITY- oppID (attribute)- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))OPPORTUNITY_CUSTOMER- oppID (attribute)- customerID (attribute)- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))The requirements of a form are:- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. - Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. how can i get the above done? how's the coding requirement be like? 	EOModeler can build a valid many-to-many relationship between Company and Opportunity.  This is preferable to building these relationships manually because it's easy to make a mistake.  Click the Tools > Table Mode EOModeler menu.  Select the model name (the top node along the left edge of the EOModeler window).  In the right section of the window, select the Company and Opportunity entities.  Click the Property > Join in Many to Many menu item.  This will create Company.opportunities and Opportunity.companies to-many relationships that are flattened across the Opportunity_Company join entity.  Inspect the Opportunity_Company entity to make sure that it has the correct table name.  You may rename the Opportunity_Company entity to Opportunity_Customer and the Opportunity.companies relationship to Opportunity.customers if you prefer.	Then when the form is submitted, iterate through the selected companies adding each company to the Opportunity.customers relationship:	opportunity.addObjectToBothSidesOfRelationshipWithKey(selectedCompany, "customers");Then send a saveChanges() message to the editing context.  Your eomodel will guide EOF to automatically manage the Opportunity_Customer entity which you don't need to refer to in your code or even to generate a custom Java class for; just leave it an EOGenericRecord. Aloha, Art   ___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/jimwong%40thegnow.comThis email sent to [EMAIL PROTECTED]  ___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/markm%40onpointsoftware.comThis email sent to [EMAIL PROTECTED]  ___D

Re: Sophisticated relationship help

2006-02-26 Thread Mark Morris
Hello Jim,You'll be safest if you stick to using flattened relationships for many-to-many's, and for nothing else.I haven't used Art's method, but he says it'll create the flattened relationship for you, so just leave it at that.  Make sure the non-flattened relationships (the ones directly to and from OPPORTUNITY_CUSTOMER) are not exposed to the class (uncheck the diamond column in EOModeler, and make sure any java classes don't have methods calling those relationships directly).Finally, you can modify the code I sent earlier like this (and again, I haven't run or debugged this):	public boolean opportunityHasCompany() {	   return anOpportunity.companies().containsObject( currentCompany );	}	public void setOpportunityHasCompany( boolean value ) {	   if( value && !opportunityHasCompany() ) {	      anOpportunity.addObjectToBothSidesOfRelationshipWithKey( currentCompany, "companies" );	   }	   if( !value && opportunityHasCompany() ) {	      companyArray.removeObjectFromBothSidesOfRelationshipWithKey( currentCompany, "companies" );	   }	}Where "companies" is the flattened many-to-many from Opportunity to Company, anOpportunity is the Opportunity being modified, and currentCompany is the "item" in the WORepetition.Regards,MarkOn Feb 26, 2006, at 2:21 AM, Jim Wong wrote:thanks art. what's flattened relationships? i can't catch wat the WO tutorial is talking abt. when do i use flattened and when do i not use? any pros and cons? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 26 Feb 2006, at 4:10 PM, Art Isbell wrote:On Feb 25, 2006, at 9:10 PM, Jim Wong wrote:I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. COMPANY- companyID (attribute)OPPORTUNITY- oppID (attribute)- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))OPPORTUNITY_CUSTOMER- oppID (attribute)- customerID (attribute)- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))The requirements of a form are:- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. - Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. how can i get the above done? how's the coding requirement be like? 	EOModeler can build a valid many-to-many relationship between Company and Opportunity.  This is preferable to building these relationships manually because it's easy to make a mistake.  Click the Tools > Table Mode EOModeler menu.  Select the model name (the top node along the left edge of the EOModeler window).  In the right section of the window, select the Company and Opportunity entities.  Click the Property > Join in Many to Many menu item.  This will create Company.opportunities and Opportunity.companies to-many relationships that are flattened across the Opportunity_Company join entity.  Inspect the Opportunity_Company entity to make sure that it has the correct table name.  You may rename the Opportunity_Company entity to Opportunity_Customer and the Opportunity.companies relationship to Opportunity.customers if you prefer.	Then when the form is submitted, iterate through the selected companies adding each company to the Opportunity.customers relationship:	opportunity.addObjectToBothSidesOfRelationshipWithKey(selectedCompany, "customers");Then send a saveChanges() message to the editing context.  Your eomodel will guide EOF to automatically manage the Opportunity_Customer entity which you don't need to refer to in your code or even to generate a custom Java class for; just leave it an EOGenericRecord. Aloha, Art   ___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/jimwong%40thegnow.comThis email sent to [EMAIL PROTECTED]  ___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/markm%40onpointsoftware.comThis email sent to [EMAIL PROTECTED]  ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Re: Sophisticated relationship help

2006-02-26 Thread Jim Wong
thanks art. what's flattened relationships? i can't catch wat the WO tutorial is talking abt. when do i use flattened and when do i not use? any pros and cons? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 26 Feb 2006, at 4:10 PM, Art Isbell wrote:On Feb 25, 2006, at 9:10 PM, Jim Wong wrote:I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. COMPANY- companyID (attribute)OPPORTUNITY- oppID (attribute)- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))OPPORTUNITY_CUSTOMER- oppID (attribute)- customerID (attribute)- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))The requirements of a form are:- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. - Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. how can i get the above done? how's the coding requirement be like? 	EOModeler can build a valid many-to-many relationship between Company and Opportunity.  This is preferable to building these relationships manually because it's easy to make a mistake.  Click the Tools > Table Mode EOModeler menu.  Select the model name (the top node along the left edge of the EOModeler window).  In the right section of the window, select the Company and Opportunity entities.  Click the Property > Join in Many to Many menu item.  This will create Company.opportunities and Opportunity.companies to-many relationships that are flattened across the Opportunity_Company join entity.  Inspect the Opportunity_Company entity to make sure that it has the correct table name.  You may rename the Opportunity_Company entity to Opportunity_Customer and the Opportunity.companies relationship to Opportunity.customers if you prefer.	Then when the form is submitted, iterate through the selected companies adding each company to the Opportunity.customers relationship:	opportunity.addObjectToBothSidesOfRelationshipWithKey(selectedCompany, "customers");Then send a saveChanges() message to the editing context.  Your eomodel will guide EOF to automatically manage the Opportunity_Customer entity which you don't need to refer to in your code or even to generate a custom Java class for; just leave it an EOGenericRecord. Aloha, Art   ___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/jimwong%40thegnow.comThis email sent to [EMAIL PROTECTED]  ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Re: Sophisticated relationship help

2006-02-26 Thread Art Isbell
On Feb 25, 2006, at 9:10 PM, Jim Wong wrote:I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. COMPANY- companyID (attribute)OPPORTUNITY- oppID (attribute)- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))OPPORTUNITY_CUSTOMER- oppID (attribute)- customerID (attribute)- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))The requirements of a form are:- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. - Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. how can i get the above done? how's the coding requirement be like? 	EOModeler can build a valid many-to-many relationship between Company and Opportunity.  This is preferable to building these relationships manually because it's easy to make a mistake.  Click the Tools > Table Mode EOModeler menu.  Select the model name (the top node along the left edge of the EOModeler window).  In the right section of the window, select the Company and Opportunity entities.  Click the Property > Join in Many to Many menu item.  This will create Company.opportunities and Opportunity.companies to-many relationships that are flattened across the Opportunity_Company join entity.  Inspect the Opportunity_Company entity to make sure that it has the correct table name.  You may rename the Opportunity_Company entity to Opportunity_Customer and the Opportunity.companies relationship to Opportunity.customers if you prefer.	Then when the form is submitted, iterate through the selected companies adding each company to the Opportunity.customers relationship:	opportunity.addObjectToBothSidesOfRelationshipWithKey(selectedCompany, "customers");Then send a saveChanges() message to the editing context.  Your eomodel will guide EOF to automatically manage the Opportunity_Customer entity which you don't need to refer to in your code or even to generate a custom Java class for; just leave it an EOGenericRecord. Aloha, Art   ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Sophisticated relationship help

2006-02-25 Thread Jim Wong
Can seem to get the below logic to work in my app.need your help. thanks.I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. COMPANY- companyID (attribute)OPPORTUNITY- oppID (attribute)- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))OPPORTUNITY_CUSTOMER- oppID (attribute)- customerID (attribute)- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))The requirements of a form are:- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. - Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. how can i get the above done? how's the coding requirement be like?  Warmest Regards,Jim Wong[EMAIL PROTECTED] On 26 Feb 2006, at 12:59 AM, Mark Morris wrote:Yes, it is bound to WORepetition's "item".  WORepetition will put into it the current Object from the "list".  It can be any object. :-)Regards,MarkOn Feb 25, 2006, at 8:26 AM, Jim Wong wrote:thanks for reply.the currentCompany you specified can be any object right? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 25 Feb 2006, at 10:00 PM, Mark Morris wrote:Hi Jim,Sorry it took a little longer to get back with you.  I had gone to bed (and I see there's a big time difference between us).It will get called automatically when the form is submitted, by the WOCheckBox component, and it will pass in the current value of the checkbox (true for checked, false for unchecked).This is very handy, and you can make your checkboxes do and reflect just about anything you can think of!  :-)Regards,MarkOn Feb 25, 2006, at 2:54 AM, Jim Wong wrote:Hi Mark:1 question: when will the setCompanyIsInArray() ever be called? do i have to invoke this method somewhere? Warmest Regards,Jim Wong[EMAIL PROTECTED] On 25 Feb 2006, at 3:39 PM, Mark Morris wrote:Hello Jim,You can use the "isChecked" binding to do this.For example, bind it to a method named "companyIsInArray".  Assume your WORepetition's "item" binding is set to "currentCompany", and the destination (mutable) array is called "companyArray".  Then write something like (warning, not debugged!):	public boolean companyIsInArray() {	   return companyArray.containsObject( currentCompany );	}	public void setCompanyIsInArray( boolean value ) {	   if( value && !companyIsInArray() ) {	      companyArray.addObject( currentCompany );	   }	   if( !value && companyIsInArray() ) {	      companyArray.removeObject( currentCompany );	   }	}This would do what you want.Regards,MarkOn Feb 24, 2006, at 11:34 PM, Jim Wong wrote: I want to display a list of objects from entity COMPANY. the list will be displayed using WORepetition. Each line will contain the companyName and a WOCheckBox. When "GO" button is clicked, I want to pass all the selections into a NSMutableArray. But I dunno how to code this. ANyone can help? Thanks.Jim___Do not post admin requests to the list. They will be ignored.Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/webobjects-dev/markm%40onpointsoftware.comThis email sent to [EMAIL PROTECTED]   ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com