• 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: login docs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: login docs


  • Subject: Re: login docs
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Sat, 08 Mar 2003 19:55:33 +0000

Kenny you will recieve this in two parts, it's the full working code of the
Authors application that you have been tying to put together.
It should be fine just take the relevant pages and and overwrite the code
you have created or simple overwite the code that's not working for you.

This post has the AuthorBookEdit.java and Book.java

The next one will
have the Session.java, Main.java and Author.java


// Generated by the WebObjects Wizard Mon Apr 08 14:03:03 GMT 2002

import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;

public class AuthorBookEdit extends WOComponent {
   protected Author author;
   protected Book bookItem;
   protected Book bookTitle;

   public AuthorBookEdit(WOContext context) {
       super(context);
   }


public Author author() { return author; } public void setAuthor(Author newAuthor) { author = newAuthor; }

   public WOComponent deleteBook() {
       // get editing context from book object
       EOEditingContext ec = bookItem.editingContext();
       // delete book from its editing context
       ec.deleteObject(bookItem);
       // remove object from relationship
       author.removeObjectFromBothSidesOfRelationshipWithKey(bookItem,
                                                             "books");
       return null;
   }


public WOComponent addBook() { // get editing context EOEditingContext ec = session().defaultEditingContext(); // create new book object Book newBook = new Book(); newBook.setTitle("New Book"); // insert new book into editing context ec.insertObject(newBook); // add new book to books and set author for it author.addObjectToBothSidesOfRelationshipWithKey(newBook, "books"); return null; /* Alternatively, you could have set each relationship individually, Eg. Method calls to add a book and set its author: author.addToBooks(newBook); newBook.setAuthor(author);*/ }



   public Main returnToMain() {
       Main nextPage = (Main)pageWithName("Main");

       // Initialize your component here

       return nextPage;
   }

   public Book bookTitle() {
       return bookTitle;
   }
   public void setBookTitle(Book newBookTitle) {
       bookTitle = newBookTitle;
   }

}
================================================



// Book.java
// Created on Mon Apr 08 14:47:54  2002 by Apple EOModeler Version 5.0

import java.math.*;
import java.util.*;
import com.webobjects.foundation.*;
import com.webobjects.eocontrol.*;

public class Book extends EOGenericRecord {

   public Book() {
       super();
       setTitle("*optional*");
   }

   public String title() {
       return (String)storedValueForKey("title");
   }

   public void setTitle(String value) {
       takeStoredValueForKey(value, "title");
   }


// This code implements a to-one relationship from // Book (one) to Author (to one). public Author author() { return (Author)storedValueForKey("author"); }

   public void setAuthor(Author value) {
   takeStoredValueForKey(value, "author");
   }


// This code implements the to-many relationship between // Author (one) and Book, books (to many). public NSArray books() { return (NSArray)storedValueForKey("books"); } public void setBooks(NSMutableArray value) { takeStoredValueForKey(value, "books"); } public void addToBooks(Book object) { NSMutableArray array = (NSMutableArray)books(); willChange(); array.addObject(object); } public void removeFromBooks(Book object) { NSMutableArray array = (NSMutableArray)books(); willChange(); array.removeObject(object); } }


From: Kenny Sabarese <email@hidden>
To: email@hidden
Subject: login docs
Date: Sat, 8 Mar 2003 11:18:39 -0800

i'm looking to make a simple login against the openbase DB as my first
real foray into WO (basically something that isn't in the book)

is there a place for directions and sample code. i tried to modify the
"authors" example in the WO book but i got a bunch of errors.

any hints at all would be great. i'm looking for something extremely
basic. if that is possible.

----------------------
Kenny Sabarese
email@hidden
http://kenny.sabarese.net


_________________________________________________________________
Surf together with new Shared Browsing http://join.msn.com/?page=features/browse&pgmarket=en-gb&XAPID=74&DI=1059
_______________________________________________
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.

  • Prev by Date: Re: login docs
  • Next by Date: Re: Bindings From 2 Entities - How?
  • Previous by thread: Re: login docs
  • Next by thread: Re: webobjects-dev digest, Vol 1 #146 - 8 msgs
  • Index(es):
    • Date
    • Thread