Package com.webobjects.directtoweb

Examples of com.webobjects.directtoweb.D2WContext


            // this will get thrown when a page simply isn't found. We don't really need to report it
            actionLog.debug("dynamicPageForActionNamed failed for Action:" + anActionName, ex);
            return null;
        }

        D2WContext context = null;
        if(newPage instanceof D2WPage) {
            context = ((D2WPage)newPage).d2wContext();
        } else {
            context = ERD2WContext.newContext(session());
            context.setDynamicPage(anActionName);
        }
        EOEntity entity = context.entity();

        if(entity != null) {
            String entityName = entity.name();
            String taskName = context.task();

            if(newPage instanceof EditPageInterface && taskName.equals("edit")) {
                prepareEditPage(context, (EditPageInterface)newPage, entityName);
            } else if(newPage instanceof InspectPageInterface) {
                prepareInspectPage(context, (InspectPageInterface)newPage, entityName);
View Full Code Here


    }

    @Override
    public boolean evaluateWithObject(Object o) {
        // FIXME here -- this could be sth else..
        D2WContext c=(D2WContext)o;
        EOEntity e=(EOEntity)c.valueForKeyPath(_keyPath);
        return isKindOfEntity(e);
    }
View Full Code Here

    }

    public String displayNameForPageConfiguration() {
        NSSelector sel = new NSSelector("d2wContext");
        if(sel.implementedByObject(context().page())) {
            D2WContext context = (D2WContext) context().page().valueForKey("d2wContext");
            return (String) context.valueForKey("displayNameForPageConfiguration");
        } else {
            if(_d2wContext == null)
                _d2wContext = ERD2WContext.newContext();
            synchronized(_d2wContext) {
                _d2wContext.setDynamicPage(ERD2WFactory.pageConfigurationFromPage(context().page()));
View Full Code Here

     *
     * @return an array of sort orderings for the destination entity.
     */
    public NSArray defaultSortOrderingsForDestinationEntity() {
        if (_defaultSortOrderingsForDestinationEntity == null) {
            final D2WContext context = ERD2WContext.newContext();
            final NSArray sortOrderingDefinition;
            final int sortOrderingDefinitionCount;
            NSMutableArray sortOrderings = null;
            int i = 0;

            context.setEntity(destinationEntity());
            sortOrderingDefinition = (NSArray)context.valueForKey("defaultSortOrdering");
            sortOrderingDefinitionCount = sortOrderingDefinition != null ? sortOrderingDefinition.count() : 0;

            while (i < sortOrderingDefinitionCount) {
                final String key = (String)sortOrderingDefinition.objectAtIndex(i++);
                final String selectorKey = (String)sortOrderingDefinition.objectAtIndex(i++);
View Full Code Here

     * Gets the CSS class(es) for the container element, based on the current entity and task.
     * @return the css classes
     */
    public String cssClassForPageContainerElement() {
        NSMutableArray classes = new NSMutableArray();
        D2WContext d2wContext = d2wContext();
    String task = d2wContext.task();
    String subTask = (String)d2wContext.valueForKey("subTask");
    String elementClassPrefix = ERXStringUtilities.capitalize(task) + "Table";
    classes.addObject(elementClassPrefix);
    if (subTask != null) {
      classes.addObject(ERXStringUtilities.capitalize(task) + ERXStringUtilities.capitalize(subTask) + "Table");
    }
    if (d2wContext.dynamicPage() != null && d2wContext.dynamicPage().indexOf("Embedded") > -1) {
      classes.addObject(ERXStringUtilities.capitalize(task) + "Embedded");
      classes.addObject("embedded");
    }
        if (entityName() != null) {
            classes.addObject(elementClassPrefix + entityName());
        }
        classes.addObject(elementClassPrefix + d2wContext.dynamicPage());
    return classes.componentsJoinedByString(" ");
    }
View Full Code Here

        // a tab page
        // D2W gets very confused about the keys. It will assume that the
        // objects on the second tab somehow belong to the first
        // resetting the cache when setting a new page configuration prevents
        // this
        D2WContext subContext = (D2WContext) valueForKey("subContext");
        ERD2WUtilities.resetContextCache(subContext);
        subContext.setDynamicPage((String) valueForBinding("_dynamicPage"));
        subContext.takeValueForKey(D2WModel.One, D2WModel.FrameKey);
        subContext.takeValueForKey(session(), D2WModel.SessionKey);
    }
View Full Code Here

        if (log.isDebugEnabled()) log.debug(hashCode() + ": context: " + _context);
        return _context;
    }

    public static D2WContext makeSubContextForTaskAndEntity(String s, EOEntity eoentity, WOSession wosession) {
        D2WContext d2wcontext = ERD2WContext.newContext(wosession);
        d2wcontext.setTask(s);
        d2wcontext.setEntity(eoentity);
        d2wcontext.takeValueForKey(D2WModel.One, D2WModel.FrameKey);
        return d2wcontext;
    }
View Full Code Here

        d2wcontext.takeValueForKey(D2WModel.One, D2WModel.FrameKey);
        return d2wcontext;
    }

    public static D2WContext makeSubContextForDynamicPageNamed(String s, WOSession wosession) {
        D2WContext d2wcontext = ERD2WContext.newContext(wosession);
        d2wcontext.setDynamicPage(s);
        // NOTE AK: for whatever reason, when you set a page config
        d2wcontext.setEntity(d2wcontext.entity());
        d2wcontext.setTask(d2wcontext.task());
        d2wcontext.takeValueForKey(D2WModel.One, D2WModel.FrameKey);
        return d2wcontext;
    }
View Full Code Here

     * @param cssKey from the d2wContext that defines the CSS for this element
     * @return the css classes
     */
    private String _cssClassForTemplateForCurrentPropertyKey(String cssKey) {
        NSMutableArray classes = new NSMutableArray();
        D2WContext d2wContext = d2wContext();
        String propertyKey = d2wContext.propertyKey();
        if (propertyKey != null) {
            classes.addObject(propertyKey.replaceAll("\\.", "_"));

            // Required?
            if (ERXValueUtilities.booleanValue(d2wContext.valueForKey("displayRequiredMarker")) && !"query".equals(task())) {
                classes.addObject("required");
            }

            // Has error?
            if (hasValidationExceptionForPropertyKey()) {
                classes.addObject("error");
            }

            // Explicitly defined class(es).
            NSArray explicitClasses = ERXValueUtilities.arrayValueWithDefault(d2wContext.valueForKey(cssKey), NSArray.EmptyArray);
            if (explicitClasses.count() > 0) {
                classes.addObjectsFromArray(explicitClasses);
            }
        }
        return classes.componentsJoinedByString(" ");
View Full Code Here

         * @throws NSValidation.ValidationException when the validation fails
         */
        public void validateValueForQueryKey(Object value, String key) throws NSValidation.ValidationException {
            if( value instanceof NSKeyValueCoding.Null) { value = null; }

            D2WContext d2wContext = d2wContext();
            String propertyKey = propertyKeyFromDisplayGroupKey(key);
            d2wContext().setPropertyKey(propertyKey);

            if (null == value && !ERXValueUtilities.booleanValueWithDefault(d2wContext.valueForKey(ValidationKeys.AllowsEmptyQueryValue), true)) {
                throw ERXValidationFactory.defaultFactory().createCustomException(null, propertyKey, value, "QueryValueRequired");
            }

            EOAttribute attribute = null;
            if (ERXValueUtilities.booleanValue(d2wContext.valueForKey("isAttribute"))) {
                attribute = d2wContext.attribute();
            } else {
                EORelationship relationship = d2wContext.relationship();
                if (relationship != null && !(value instanceof EOEnterpriseObject)) {
                    String keyWhenRelationship = (String)d2wContext.valueForKey("keyWhenRelationship");
                    if (keyWhenRelationship != null) {
                        EOEntity destinationEntity = relationship.destinationEntity();
                        attribute = destinationEntity.attributeNamed(keyWhenRelationship);
                    }
                }
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.