epi.setObject(aNewEO); epi.setNextPage(context().page()); nextPage=(WOComponent)epi;
} epi.setObject(aNewEO); epi.setNextPage(context().page()); nextPage=(WOComponent)epi;
    public WOComponent newObjectAction() {        WOComponent nextPage=null;        EOEntity entity=EOModelGroup.defaultGroup().entityNamed(_manipulatedEntityName);        EOClassDescription aClassDesc=entity.classDescriptionForInstances();        if (isEntityReadOnly(entity)) {            ErrorPageInterface api=D2W.factory().errorPage(session());            api.setMessage("<b>You can not create new instances of "+_manipulatedEntityName+"</b><br><br>It is read-only.");            api.setNextPage(context().page());            nextPage=(WOComponent)api;        } else {            EOEditingContext peerContext=ERXExtensions.newEditingContext(session().defaultEditingContext().parentObjectStore());            EOEnterpriseObject aNewEO=(EOEnterpriseObject)aClassDesc.createInstanceWithEditingContext(peerContext, null);            peerContext.insertObject(aNewEO);            try {                if (_manipulatedEntityName.equals("TestItem")) {                    epi=(EditPageInterface)D2W.factory().pageForConfigurationNamed("EditNewTestItem",session());                    EOEnterpriseObject localUser=EOUtilities.localInstanceOfObject(aNewEO.editingContext(),                                                                                   ((Session)session()).getUser());                    aNewEO.addObjectToBothSidesOfRelationshipWithKey(localUser,"owner");                                        }else if (_manipulatedEntityName.equals("Bug")) {                        epi=(EditPageInterface)D2W.factory().pageForConfigurationNamed("EditNewBug",session());                        EOEnterpriseObject localUser=EOUtilities.localInstanceOfObject(aNewEO.editingContext(),                                                                                       ((Session)session()).getUser());                        aNewEO.addObjectToBothSidesOfRelationshipWithKey(localUser,"originator");                    }else if (_manipulatedEntityName.equals("Requirement")) {                            epi=(EditPageInterface)D2W.factory().pageForConfigurationNamed("EditNewRequirement",session());                            EOEnterpriseObject localUser=EOUtilities.localInstanceOfObject(aNewEO.editingContext(),                                                                                           ((Session)session()).getUser());                            aNewEO.addObjectToBothSidesOfRelationshipWithKey(localUser,"originator"); }                    else                    epi=D2W.factory().editPageForEntityNamed(_manipulatedEntityName, session());                    epi.setObject(aNewEO);                    epi.setNextPage(context().page());                    nextPage=(WOComponent)epi;            } catch (IllegalArgumentException e) {                ErrorPageInterface epf=D2W.factory().errorPage(session());                epf.setMessage(e.toString());                epf.setNextPage(context().page());                nextPage=(WOComponent)epf;            }        }        return nextPage;    }