• 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: newbie creating object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie creating object


  • Subject: Re: newbie creating object
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 12 Dec 2007 09:06:53 -0800

Please keep messages on the list.

Again, I would look at the tutorial

http://wotutorial.furfly.com/

and see how what you have differs from that. Following that will lead you away from some bad habits that you are starting with.

I don't see any obvious errors in the code below.


Chuck


On Dec 12, 2007, at 3:44 AM, Theodore Petrosky wrote:

This is a test. I wanted to accomplish one thing.
(well a couple)
1. use the eomodeler to create the table with only two
rows. the identifier and a text row.
2. successfully create this table in the database.
3. get eogenerator to create the java object for my
model
4. instantiate a copy of an object in my 'main'
component.

I believe that I have created the object definintion.
Velocity Generator created the com.wotest.eo.thetable
in the correct place (Sources).

Here is my Main.java:

import com.webobjects.appserver.WOComponent;
import com.webobjects.appserver.WOContext;
import com.webobjects.eoaccess.EOUtilities;
import com.wothest.eo.thetable;

public class Main extends WOComponent {
	private static final long serialVersionUID = 1L;
	public thetable newtable;

	public Main(WOContext context) {
		super(context);
		newtable = new thetable();
	}
}

If I comment out //newtable = new thetable();

I get a "Hello World" page.

Here is thetable.java:

package com.wothest.eo;

import org.apache.log4j.Logger;

public class thetable extends _thetable {
  private static Logger log =
Logger.getLogger(thetable.class);
}

this is _thetable.java:

// DO NOT EDIT.  Make changes to thetable.java
instead.
package com.wothest.eo;

import com.webobjects.eoaccess.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import java.math.*;
import java.util.*;
import org.apache.log4j.Logger;

@SuppressWarnings("all")
public abstract class _thetable extends
EOGenericRecord {
	public static final String ENTITY_NAME = "thetable";

	// Attributes
	public static final String FIRSTNAME_KEY =
"firstname";

	// Relationships

  private static Logger LOG =
Logger.getLogger(_thetable.class);

  public thetable
localInstanceOfthetable(EOEditingContext
editingContext) {
    thetable localInstance =
(thetable)EOUtilities.localInstanceOfObject(editingContext,
this);
    if (localInstance == null) {
      throw new IllegalStateException("You attempted
to localInstance " + this + ", which has not yet
committed.");
    }
    return localInstance;
  }

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

  public void setFirstname(String value) {
    if (_thetable.LOG.isDebugEnabled()) {
    	_thetable.LOG.debug( "updating firstname from " +
firstname() + " to " + value);
    }
    takeStoredValueForKey(value, "firstname");
  }

  public static thetable
createthetable(EOEditingContext editingContext, String
firstname
) {
    thetable eo =
(thetable)EOUtilities.createAndInsertInstance(editingContext,
_thetable.ENTITY_NAME);
		eo.setFirstname(firstname);
    return eo;
  }

  public static NSArray<thetable>
fetchAllthetables(EOEditingContext editingContext) {
    return _thetable.fetchAllthetables(editingContext,
null);
  }

  public static NSArray<thetable>
fetchAllthetables(EOEditingContext editingContext,
NSArray<EOSortOrdering> sortOrderings) {
    return _thetable.fetchthetables(editingContext,
null, sortOrderings);
  }

public static NSArray<thetable>
fetchthetables(EOEditingContext editingContext,
EOQualifier qualifier, NSArray<EOSortOrdering>
sortOrderings) {
EOFetchSpecification fetchSpec = new
EOFetchSpecification(_thetable.ENTITY_NAME, qualifier,
sortOrderings);
fetchSpec.setIsDeep(true);
NSArray<thetable> eoObjects =
(NSArray<thetable>)editingContext.objectsWithFetchSpecification (fetchSpec);
return eoObjects;
}


  public static thetable
fetchthetable(EOEditingContext editingContext, String
keyName, Object value) {
    return _thetable.fetchthetable(editingContext, new
EOKeyValueQualifier(keyName,
EOQualifier.QualifierOperatorEqual, value));
  }

  public static thetable
fetchthetable(EOEditingContext editingContext,
EOQualifier qualifier) {
    NSArray<thetable> eoObjects =
_thetable.fetchthetables(editingContext, qualifier,
null);
    thetable eoObject;
    int count = eoObjects.count();
    if (count == 0) {
      eoObject = null;
    }
    else if (count == 1) {
      eoObject = (thetable)eoObjects.objectAtIndex(0);
    }
    else {
      throw new IllegalStateException("There was more
than one thetable that matched the qualifier '" +
qualifier + "'.");
    }
    return eoObject;
  }

  public static thetable
fetchRequiredthetable(EOEditingContext editingContext,
String keyName, Object value) {
    return
_thetable.fetchRequiredthetable(editingContext, new
EOKeyValueQualifier(keyName,
EOQualifier.QualifierOperatorEqual, value));
  }

  public static thetable
fetchRequiredthetable(EOEditingContext editingContext,
EOQualifier qualifier) {
    thetable eoObject =
_thetable.fetchthetable(editingContext, qualifier);
    if (eoObject == null) {
      throw new NoSuchElementException("There was no
thetable that matched the qualifier '" + qualifier +
"'.");
    }
    return eoObject;
  }

  public static thetable
localInstanceOfthetable(EOEditingContext
editingContext, thetable eo) {
    thetable localInstance = (eo == null) ? null :
(thetable)EOUtilities.localInstanceOfObject(editingContext,
eo);
    if (localInstance == null && eo != null) {
      throw new IllegalStateException("You attempted
to localInstance " + eo + ", which has not yet
committed.");
    }
    return localInstance;
  }
}


Can you help with this? I don't get what I am doing wrong.

Ted


--- Chuck Hill <email@hidden> wrote:


On Dec 11, 2007, at 7:44 PM, Theodore Petrosky wrote:

Okay, I have a little experience with WO using
xcode
and I am trying to understand eclipse. I have what
I
consider a very simple example and I need to
understand what is going on.

Eclipse 3.3.1.1
WOlips 3.3.4742

I am trying to create a new object. I am connected
to
a postgresql backend. I created a table that has a
primary key (integer) and a single text column
called
firstname. I generated the object using the
Velocity
EOgenerator as I could never get the
javaEOGenerator
to work...

Everything appears to be okay until I try to
create a
new object.  I tried:

newtable = new thetable();

That is a rather odd / poor choice of name for an entity. May I suggest a tutorial?

http://wotutorial.furfly.com/

It is not complete, but you may find it useful.


Eclipse complains that I need to import thetable
and I
import it.

Xcode would complain of the same thing.


So the only thing I have is a "Hello World"
web page where I am trying to create an object.
This
is my error:

Application: wotest
Error: java.lang.reflect.InvocationTargetException
exception
Reason:
java.lang.reflect.InvocationTargetException

What am I doing wrong? I need some help. I feel
like I
am about to give up on webobjects. I used to get
it
working fairly easily with xcode...


I don't see that this has _anything_ do with with
Xcode vs Eclipse.
You have an error in  your code somewhere.  Is there
any more to the
error message than that?

Chuck

--

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









______________________________________________________________________ ______________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/ newsearch/category.php?category=shopping



--

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:
This email sent to email@hidden


  • Prev by Date: Re: Flex integration with WO
  • Next by Date: Re: Flex integration with WO
  • Previous by thread: Re: newbie creating object
  • Next by thread: WO In Around DC/ MD/ VA For Windows?
  • Index(es):
    • Date
    • Thread