Package com.webobjects.directtoweb

Examples of com.webobjects.directtoweb.D2WContext


        return c;
    }

    public ERD2WController controllerForName(String controllerName, WOSession session) {
        myCheckRules();
        D2WContext newContext=ERD2WContext.newContext(session);
        newContext.takeValueForKey(controllerName, "controllerName");
        // give an InstanceCreationAssigment a chance
        ERD2WController c = controllerInstanceWithContext(newContext);

        return c;
    }
View Full Code Here


        return c;
    }

    public ERD2WController controllerForTaskAndEntityNamed(String task, String entityName, WOSession session) {
        myCheckRules();
        D2WContext newContext=ERD2WContext.newContext(session);
        newContext.setTask(task);
        EOEntity newEntity=entityName!=null ? EOModelGroup.defaultGroup().entityNamed(entityName) : null;
        if (newEntity!=null) newContext.setEntity(newEntity);
        String controllerName="__"+task+"__"+entityName;
        // saves 2 significant keys, task and entity!
        newContext.takeValueForKey(controllerName,"controllerName");

        ERD2WController c = controllerInstanceWithContext(newContext);

        return c;
    }
View Full Code Here

     * @param context the current context
     * @return a dictionary of D2W-related keys to describe the D2W state of the context.
     */
    public static synchronized NSMutableDictionary informationForContext(WOContext context) {
        NSMutableDictionary info = new NSMutableDictionary();
        D2WContext d2wContext = null;
        NSArray componentStack = ERXWOContext._componentPath(context);
        // Try to get the information for the D2WPage closest to the end of the component stack, i.e., more specific
        // info., that is especially helpful for finding problems in embedded page configurations.
        WOComponent component = null;
        for (Enumeration componentsEnum = componentStack.reverseObjectEnumerator(); componentsEnum.hasMoreElements();) {
            WOComponent c = (WOComponent)componentsEnum.nextElement();
            if (c instanceof D2WPage) {
                component = c;
                break;
            }
        }
        if (null == component) { // Fall back to the highest level page.
            component = context.page();
        }

        try {
            d2wContext = (D2WContext)component.valueForKey("d2wContext");
        } catch (NSKeyValueCoding.UnknownKeyException uke) {
            if (log.isInfoEnabled()) {
                log.info("Could not retrieve D2WContext from component context; it is probably not a D2W component.");
            }
        }

        if (d2wContext != null) {
            NSMutableDictionary d2wInfo = informationForD2WContext(d2wContext);
            if (component instanceof ERD2WPage) {
                ERD2WPage currentPage = (ERD2WPage)component;
                String subTask = (String)d2wContext.valueForKey("subTask");
                if ("tab".equals(subTask) || "wizard".equals("subTask")) {
                    NSArray sections = currentPage.sectionsForCurrentTab();
                    d2wInfo.setObjectForKey(sections != null ? sections : "null", "D2W-SectionsContentsForCurrentTab");
                    d2wInfo.removeObjectForKey("D2W-TabSectionsContents");
                }
View Full Code Here

        public ERCQuery() {
            super();
        }

        public WOComponent searchAction(WOComponent currentPage) {
            D2WContext d2wContext = ((D2WComponent)currentPage.parent()).d2wContext();
            EODataSource ds = ((QueryPageInterface)currentPage.parent()).queryDataSource();
            log.info("searchAction: " + ds);
            ListPageInterface listpageinterface = null;
            String listConfigurationName=(String)d2wContext.valueForKey("listConfigurationName");
            if(listConfigurationName==null) {
                listConfigurationName = "__list__" + d2wContext().entity().name();
            }
            listpageinterface = (ListPageInterface)pageForConfigurationNamed(listConfigurationName);
            listpageinterface.setDataSource(ds);
View Full Code Here

        return defaultListPageDisplayGroupDelegate;
    }

  @Override
    public WOComponent defaultPage(WOSession wosession) {
        D2WContext d2wcontext = ERD2WContext.newContext(wosession);
        return pageWithContextTaskEntity(d2wcontext, d2wcontext.startupTask(), d2wcontext.startupEntityName(), wosession.context());
    }
View Full Code Here

    }

  @Override
    public WOComponent pageForConfigurationNamed(String name, WOSession s) {
        myCheckRules();
        D2WContext d2wcontext = ERD2WContext.newContext(s.context().session());
        d2wcontext.setDynamicPage(name);
        if (d2wcontext.task() == null || d2wcontext.entity() == null) {
            String reason = null;
            if (d2wcontext.task() == null && d2wcontext.entity() == null) {
                reason = "task and entity is null, it seems that one model, maybe ERDirectToWeb d2w.d2wmodel is not loaded!";
            } else if (d2wcontext.task() == null) {
                reason = "task is null, it seems that one model, maybe ERDirectToWeb d2w.d2wmodel is not loaded!";
            } else if (d2wcontext.entity() == null) {
                reason = "entity is null, it seems that one model, maybe ERDirectToWeb d2w.d2wmodel is not loaded!";
            }
            throw new IllegalStateException("Couldn't find the dynamic page named " + name + " in your DirectToWeb model."+
                    reason);
        }
        return pageWithContextTaskEntity(d2wcontext, d2wcontext.task(), d2wcontext.entity().name(), s.context());
//      return super.pageForConfigurationNamed(name, s);
      
    }
View Full Code Here

  @Override
    public EditPageInterface editPageForNewObjectWithConfigurationNamed(String configurationName, WOSession session) {
        EditPageInterface epi = (EditPageInterface) pageForConfigurationNamed(configurationName, session);
        EOEditingContext peerContext = ERXEC.newEditingContext(session.defaultEditingContext().parentObjectStore());
        D2WContext d2wcontext = ((D2WPage) epi).d2wContext();
        EOEnterpriseObject newObject = _newObjectWithEntity(d2wcontext.entity(), peerContext);
        epi.setObject(newObject);
        peerContext.hasChanges();
        return epi;
    }
View Full Code Here

        return pageForConfigurationNamed(pageConfiguration, session);
    }

    public WOComponent printerFriendlyPageForD2WContext(D2WContext context, WOSession session) {
        myCheckRules();
        D2WContext newContext = ERD2WContext.newContext(session);
        String newTask = context.task().equals("edit") ? "inspect" : context.task();
        newContext.takeValueForKey(newTask, "task");
        // not using subTask directly here because the cache mechanism relies on
        // being able to compute wether this key
        // is 'computable' (subTask is since a rule can fire to give a default)
        // or an external output
        //        newContext.takeValueForKey("printerFriendly","subTask");
        newContext.takeValueForKey("printerFriendly", "forcedSubTask");
        newContext.takeValueForKey(context.valueForKey("pageName"), "existingPageName");
        newContext.takeValueForKey(context.valueForKey("subTask"), "existingSubTask");
        newContext.takeValueForKey(context.valueForKey("pageConfiguration"), "pageConfiguration");
        newContext.takeValueForKey(context.entity(), "entity");
        WOComponent result = WOApplication.application().pageWithName((String) newContext.valueForKey("pageName"), session.context());
        ((D2WPage) result).setLocalContext(newContext);
        return result;
    }
View Full Code Here

        return result;
    }

    public WOComponent csvExportPageForD2WContext(D2WContext context, WOSession session) {
        myCheckRules();
        D2WContext newContext = ERD2WContext.newContext(session);
        newContext.takeValueForKey(context.task(), "task");
        // not using subTask directly here because the cache mechanism relies on
        // being able to compute wether this key
        // is 'computable' (subTask is since a rule can fire to give a default)
        // or an external output
        newContext.takeValueForKey("csv", "forcedSubTask");
        newContext.takeValueForKey(context.valueForKey("pageName"), "existingPageName");
        newContext.takeValueForKey(context.valueForKey("subTask"), "existingSubTask");
        newContext.takeValueForKey(context.valueForKey("pageConfiguration"), "pageConfiguration");
        newContext.takeValueForKey(context.entity(), "entity");
        WOComponent result = WOApplication.application().pageWithName((String) newContext.valueForKey("pageName"), session.context());
        ((D2WPage) result).setLocalContext(newContext);
        return result;
    }
View Full Code Here

        return result;
    }

    public WOComponent pageForTaskSubTaskAndEntityNamed(String task, String subtask, String entityName, WOSession session) {
        myCheckRules();
        D2WContext newContext = ERD2WContext.newContext(session);
        newContext.setTask(task);
        newContext.setEntity(_entityNamed(entityName, session));
        newContext.takeValueForKey(subtask, "subTask");
        WOComponent result = WOApplication.application().pageWithName((String) newContext.valueForKey("pageName"), session.context());
        ((D2WPage) result).setLocalContext(newContext);
        return result;
    }
View Full Code Here

TOP

Related Classes of com.webobjects.directtoweb.D2WContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.