try {
EOEditingContext ec = ERXEC.newEditingContext();
ec.lock();
try {
log.info("Creating page: " + pageName);
WOComponent page = D2W.factory().pageForConfigurationNamed(pageName, session);
context._setPageElement(page);
context._setCurrentComponent(page);
String task = ERD2WFactory.taskFromPage(page);
String entityName = ERD2WFactory.entityNameFromPage(page);
if (page instanceof InspectPageInterface) {
InspectPageInterface ipi = (InspectPageInterface) page;
ipi.setObject(EOUtilities.createAndInsertInstance(ec, entityName));
ipi.setNextPage(page);
} else if (page instanceof ListPageInterface) {
ListPageInterface lpi = (ListPageInterface) page;
lpi.setDataSource(ERXEOControlUtilities.dataSourceForArray(ec, entityName, new NSArray(EOUtilities.createAndInsertInstance(ec, entityName))));
lpi.setNextPage(page);
} else if (page instanceof SelectPageInterface) {
SelectPageInterface lpi = (SelectPageInterface) page;
lpi.setDataSource(ERXEOControlUtilities.dataSourceForArray(ec, entityName, new NSArray(EOUtilities.createAndInsertInstance(ec, entityName))));
} else if (page instanceof ConfirmPageInterface) {
ConfirmPageInterface cpi = (ConfirmPageInterface) page;
// nothing
} else if (page instanceof QueryPageInterface) {
QueryPageInterface qpi = (QueryPageInterface) page;
// nothing
} else {
log.info("Unsupported: " + pageName + " -> " + page.name());
}
page.appendToResponse(new ERXResponse(), context);
} finally {
ec.unlock();
}
} catch(Throwable t) {
log.error("Error running: " + pageName + ":" + t.getMessage() + " Tree: " + ERXWOContext.componentPath(context));