[Solved] Re: Very interesting case
[Solved] Re: Very interesting case
- Subject: [Solved] Re: Very interesting case
- From: Don Lindsay <email@hidden>
- Date: Mon, 21 Sep 2009 18:26:58 -0400
I was making it too difficult. I was able to solve the issue by using
the UserAnswers as the primary Display Group.
Don
On Sep 21, 2009, at 5:16 PM, Don Lindsay wrote:
I know, I have been piddling with it and probably violated many
commandments. Let me explain what I am doing and see if anyone has
any insight.
I have a datamodel with the following:
Users (identifier Integer, username string, password string)
Pages (identifier Integer, PageDescription string, active integer,
position Integer)
Questions (identifier integer, questiontext string, pageidentifier
integer, active integer)
Question Lookup Values (identifier, descriptivetext string, active
integer)
UserAnswers(identifier integer, useridentifier integer,
questionidentifier integer, answeridentifier integer)
Pretty simple. A user can access any page, any question on a page,
and answer a question only once. So I created an entity:
useranswers ( User, Question, Answer(would contain a question
lookup) )
Pages can have one or more questions,
Questions can have zero or more Question Lookup Values.
More than one question can relate to a question lookup value.
So the relationship looks like this:
Pages <-->> Questions <<-->> Lookup Values
User <-->> UserAnswers <<--> Question
So what I have done is create a component that takes a User as a
property when it is created setUser(...).
I then created a WODisplayGroup for Pages with no detail.
I then created a WODisplayGroup for Questions with detail pointing
to pages.
I then created a WODisplayGroup for UserAnswers with detail pointing
to questions.
The issue I have with the UserAnswers displaygroup is that it also
requires a qualification to a User as well as a question. Noooo
problemo, I use the
queryMatch().setValueForKey(theUserObject,"theUser").
Now here is where I run into issues, Question.theAnswers
relationship returns an NSArray because it is a to-many. How do I
bind this to the selection property of a WOPopupButton, I can't that
I know of. <<Violation of every commandment known occurs here>>
Don
On Sep 21, 2009, at 4:31 PM, Chuck Hill wrote:
On Sep 21, 2009, at 1:17 PM, Don Lindsay wrote:
Hello;
I have a component that I am updating a table of answers based on
selections made by the user from a worepitition.
The code being executed is:
try {
String sEoQualifierText = "page=";
sEoQualifierText +=
Integer.toString((Integer)thePage().valueForKey("identifier"));
sEoQualifierText += " and question=";
sEoQualifierText +=
Integer.toString((Integer)theQuestion().valueForKey("identifier"));
sEoQualifierText += " and user=";
sEoQualifierText += Integer.toString((Integer)
((EOEnterpriseObject)theUser).valueForKey("identifier"));
EOQualifier oQual =
EOQualifier.qualifierWithQualifierFormat(sEoQualifierText,null);
What are you doing? And why? What is
thePage().valueForKey("identifier")? Home brew binding sync?
Generic Record based EOs with no Java classes?
Wonder's ERXQ will make your life so much easier to read and
maintain.
EOFetchSpecification oFetch = new
EOFetchSpecification("UserAnswers",oQual,null);
NSArray aAnswer = oEO().objectsWithFetchSpecification(oFetch);
oEO().lock();
Nooooooooooooooooooooooo.
<runs away screaming>
Why lock like that? Why not just gouge your eyes out and hammer
pencils into your ears? It will be quicker and less painful and
just as effective.
Locking like that is useless and wrong and just won't work. Ever.
Use ERXEC or the MultiECLockManager. Your chances of doing it
right another other way approach null.
((UserAnswers
)aAnswer
.objectAtIndex(0)).setTheAnswer((QuestionLookup)theAnswer());
//((EOEnterpriseObject)aAnswer.objectAtIndex(0)).willChange();
oEO().unlock();
//System.out.println("updates to be saved: " +
oEO().updatedObjects());
oEO().saveChanges();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("hissssss, didn't work");
}
if (theAnswer!=null) {
System.out.println("append to response firing "+
(String)theAnswer.valueForKey("desc"));
} else {
System.out.println("append to response firing but the answer is
null");
}
ThePage is an item from a listing of available pages repetition.
TheQuestion is an item from listing of questions repitition.
TheUser is the user who is currently working with the page.
The entity has 4 attributes (user, page, question, answer).
When I turn on EO Debugging I see that an update is made, but when
I check the database the answer is always null. I do not get any
errors in the logs. If I had an error I could start working it out.
Anyone have any ideas?
My money is on "incorrect EC locking" followed by "violating EOF
commandments". This is the classic symptom of doing either (or
both!) of those.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@mac.com
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