PATH  WebObjects 4.0 Documentation > JavaClient Tutorial

Creating a Java Client WebObjects Application

Previous | Back Up One Level | Next

Generating Source Files

To begin creating your custom classes, generate source files for the Studio and Talent entities. You'll use these source files as a basis for adding custom behavior to your enterprise objects. Generating source files in a Java Client application typically produces "skeletal" .java files for the associated class. These files are put in the ClientSideJava.subproj subproject.

To generate source files for an entity, you must have replaced the text "EOGenericRecord" in the Class Name and Client-Side Class Name fields with a package name concatenated with a class name.

1. Generate source files.

In the Model Editor, select the entity for which you want to generate source files.

Choose Property Generate Client Java File.

In the Choose Class Name panel verify the file name and location ( ClientSideJava.subproj ) and click Save.

Click OK when you're asked if you want to insert the files in the subproject.

For the same entity, choose Property Generate Java FIle.

In the Choose Class Name panel verify the file name and location (main project) and click Save.

Click OK when you're asked if you want to insert the files in the main project.

When Project Builder generates a class file (such as Studio.java), it strips off the package prefix and inserts a package declaration near the top of the file. The class file also includes the necessary import declarations as well as the instance variables and accessor methods derived from the properties of the Studio entity.

Studio.java (ClientSideJava.subproj)

package businesslogic.client;

import com.apple.client.foundation.*;
import com.apple.client.eocontrol.*;
import java.math.BigDecimal;
import java.util.*;

public class Studio extends EOCustomObject {

        protected Number budget;
        protected String name;
    protected NSMutableArray movies;

    public Studio(EOEditingContext context, EOClassDescription classDesc, EOGlobalID gid) {
        super(context, classDesc, gid);
    }

    public Number budget() {
        willRead();
        return budget;
    }

    public void setBudget(Number value) {
        willChange();
        budget = value;
    }

    public String name() {
        willRead();
        return name;
    }

    public void setName(String value) {
        willChange();
        name = value;
}

    public NSArray movies() {
        willRead();
        return movies;
    }


    public void setMovies(NSMutableArray value) {
        willChange();
        movies = value;
    }

    public void addToMovies(EOEnterpriseObject object) {
        willChange();
        movies.addObject(object);
    }


    public void removeFromMovies(EOEnterpriseObject object) {
        willChange();
        movies.removeObject(object);
    }
}

© 1999 Apple Computer, Inc.

Previous | Back Up One Level | Next