• 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
Re: Design Question...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Design Question...


  • Subject: Re: Design Question...
  • From: LD <email@hidden>
  • Date: Fri, 1 Jul 2005 14:40:33 +1000

Hi,

On 30/06/2005, at 4:40 PM, james o wrote:

when my WOComponent is being built it iterates over items from a Question table. Each questionItem will have a corresponding pulldown menu or check box list built from a Choices table. at this point i can think of two options on storing the values in a Results table:

1. when the WORepetition is creating the pull-downs i can bind the corresponding Results table item to the pull down selection. the downside <...> won't work w/checkboxes - i'll need a join table for this.

For checkboxes, the easiest thing to do would probably be:
- create a WORepetition, for example, within your outer Question repetition. The inner repetition is the list of choices - each with a checkbox.
- for each checkbox temporarily (within your child ec) create all relationships for your scheme - but negate the checkbox so that it defaults to not being checked. That way when the form is submitted - you can adjust as necessary.


e.g.,
Question <-->> Result <<--> Choice
Result <<--> User

// WOComponent.java
NSMutableDictionary resultsPerQuestion;
NSArray questions;
NSArray choices;

public Result aResult() {
    NSMutableDictionary resultsPerChoice;
    Result result;

resultsPerChoice = (NSMutableDictionary) resultsPerQuestion.objectForKey(aQuestion);
if (resultsPerChoice == null) {
resultsPerChoice = new NSMutableDictionary();
resultsPerQuestion.setObjectForKey(resultsPerChoice, aQuestion);
}
if ((result = (Result) resultsPerChoice.objectForKey(aChoice)) == null) {
result = EOUtilities.createAndInsertInstance(localEC, "Result");
result.setChoice(aChoice); // adds to both sides of relationship
result.addObjectToBothSidesOfRelationshipWithKey(user, "user");
result.addObjectToBothSidesOfRelationshipWithKey(aQuestion, "question");
}
return result;
}
// on WOComponent render...
public Boolean resultIsSelected() {
Result result;
Choice choice;


    result = aResult();
    choice = result.choice();
    return (choice == null ? Boolean.FALSE : Boolean.TRUE);
}

// ON FORM SUBMIT...
// if false keeps relationship (on form submit)
// if true - then we're removing the relationship
public void setResultIsSelected(Boolean value) {
if (value != null && value.booleanValue()) {
aResult().setChoice(null); // removes from both sides of relationship
} else {
// aResult().setChoice(aChoice); // relationship already exists
}
}


// WOComponent.wod
AResultCheckBox: WOCheckBox {
    selection = resultIsSelected;
    value = "false"; // ***negates selection***
}
ResultsPerQuestion: WORepetition {
    list = choices;
    item = aChoice;
}

Or something like that...

with regards,
--

LD


_______________________________________________ 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
References: 
 >Design Question... (From: james o <email@hidden>)

  • Prev by Date: Re: File download
  • Next by Date: Re: webobjects 5.3 w/ xcode 2.1 runs very slow
  • Previous by thread: Re: Design Question...
  • Next by thread: changing application behaviour according to domain name
  • Index(es):
    • Date
    • Thread