On Sep 30, 2008, at 8:07 PM, Awbrey Hughlett wrote:

I have an entity named "Specific" and an attribute named "specificType". I have a WOTextField bound to specific.specificType and a WOSubmitButton bound to saveChanges() all wrapped in a WOForm. When I run the component and click to save changes to the database, I get a NullPointerException. Have I instantiated the Specific entity and inserted it into an editing context correctly? Or do I have other problems?

You have other problems, some of which you probably don't know about.




public class SpecificEntry extends WOComponent {
        private Specific specific;
        private EOEditingContext ec = new EOEditingContext();

Noooooooooo. :-) You are using an unlocked editing context. Doom awaits you. You have three choices here:

1. Start using Wonder and ERXEC
2. Use session().defaultEditingContext() - though this has issues of its own 3. Use MultiECLockManager and add the infrastructure to your apps to handle EC management.


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

    public Specific specific() {
        if (specific == null) {
                editingContext().revert();
                
specific = (Specific)EOUtilities.createAndInsertInstance(editingContext(), "Specific");
        }
        
        return specific;
    }

    public WOComponent saveChanges() {
        
        editingContext().saveChanges();
        
        setSpecific(null);
        
        return context().page();

Post the stack track for for NPE.  Guessing is too hard.


Chuck


    }

    public EOEditingContext editingContext() {
        return ec;
    }

    public void setSpecific(Specific newSpecific) {
        specific = newSpecific;
    }
}

Thanks,
Awbrey
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net

This email sent to [EMAIL PROTECTED]

--
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      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to