Search in sources :

Example 6 with WOElement

use of com.webobjects.appserver.WOElement in project wonder-slim by undur.

the class WOHelperFunctionParser method didParseClosingWebObjectTag.

public void didParseClosingWebObjectTag(String s, WOHelperFunctionHTMLParser htmlParser) throws WOHelperFunctionDeclarationFormatException, WOHelperFunctionHTMLFormatException, ClassNotFoundException {
    WOHTMLWebObjectTag webobjectTag = _currentWebObjectTag.parentTag();
    if (webobjectTag == null) {
        throw new WOHelperFunctionHTMLFormatException("<" + getClass().getName() + "> Unbalanced WebObject tags. Either there is an extra closing </WEBOBJECT> tag in the html template, or one of the opening <WEBOBJECT ...> tag has a typo (extra spaces between a < sign and a WEBOBJECT tag ?).");
    }
    try {
        WOElement element = _currentWebObjectTag.dynamicElement(_declarations, _languages);
        _currentWebObjectTag = webobjectTag;
        _currentWebObjectTag.addChildElement(element);
    } catch (RuntimeException e) {
        throw new RuntimeException("Unable to load the component named '" + componentName(_currentWebObjectTag) + "' with the declaration " + prettyDeclaration((WODeclaration) _declarations.objectForKey(_currentWebObjectTag.name())) + ". Make sure the .wo folder is where it's supposed to be and the name is spelled correctly.", e);
    }
}
Also used : WOElement(com.webobjects.appserver.WOElement)

Example 7 with WOElement

use of com.webobjects.appserver.WOElement in project wonder-slim by undur.

the class ERXWOComponentContent method appendToResponse.

@Override
public void appendToResponse(WOResponse woresponse, WOContext wocontext) {
    WOComponent component = wocontext.component();
    WOElement template = template(component);
    if (template != null) {
        wocontext._setCurrentComponent(component.parent());
        template.appendToResponse(woresponse, wocontext);
        wocontext._setCurrentComponent(component);
    } else {
        _defaultTemplate.appendToResponse(woresponse, wocontext);
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) WOElement(com.webobjects.appserver.WOElement)

Example 8 with WOElement

use of com.webobjects.appserver.WOElement in project wonder-slim by undur.

the class ERXWOComponentContent method takeValuesFromRequest.

@Override
public void takeValuesFromRequest(WORequest worequest, WOContext wocontext) {
    WOComponent component = wocontext.component();
    WOElement template = template(component);
    if (template != null) {
        wocontext._setCurrentComponent(component.parent());
        template.takeValuesFromRequest(worequest, wocontext);
        wocontext._setCurrentComponent(component);
    } else {
        _defaultTemplate.takeValuesFromRequest(worequest, wocontext);
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) WOElement(com.webobjects.appserver.WOElement)

Example 9 with WOElement

use of com.webobjects.appserver.WOElement in project wonder-slim by undur.

the class ERXWOComponentContent method template.

private WOElement template(WOComponent component) {
    WOElement content = component._childTemplate();
    WOElement result = null;
    String templateName = (_templateName == null) ? null : (String) _templateName.valueInComponent(component);
    if (content != null && content.getClass() == WODynamicGroup.class) {
        WODynamicGroup group = (WODynamicGroup) content;
        if (templateName == null) {
            // MS: If you don't set a template name, then let's construct all the children of
            // this element that are NOT ERXWOTemplate's, so we don't double-display.  This lets
            // you use an ERXWOComponentContent and have it just act like a "default" template
            // that skips all the children that are explicitly wrapped in an ERXWOTemplate.
            NSMutableArray<WOElement> originalChildrenElements = group.childrenElements();
            if (originalChildrenElements != null && originalChildrenElements.count() > 0) {
                NSMutableArray<WOElement> nonTemplateChildrenElements = new NSMutableArray<>();
                for (WOElement originalChild : originalChildrenElements) {
                    if (!(originalChild instanceof ERXWOTemplate)) {
                        nonTemplateChildrenElements.addObject(originalChild);
                    }
                }
                result = new WODynamicGroup(null, null, nonTemplateChildrenElements);
            }
        } else {
            for (Enumeration e = group.childrenElements().objectEnumerator(); e.hasMoreElements() && result == null; ) {
                WOElement current = (WOElement) e.nextElement();
                if (current instanceof ERXWOTemplate) {
                    ERXWOTemplate template = (ERXWOTemplate) current;
                    String name = template.templateName(component);
                    if (name.equals(templateName)) {
                        result = template;
                    }
                }
            }
        }
    } else if (content instanceof ERXWOTemplate) {
        ERXWOTemplate template = (ERXWOTemplate) content;
        String name = template.templateName(component);
        if (name.equals(templateName)) {
            result = template;
        }
    } else if (templateName == null) {
        result = content;
    }
    return result;
}
Also used : ERXWOTemplate(er.extensions.components.conditionals.ERXWOTemplate) Enumeration(java.util.Enumeration) WODynamicGroup(com.webobjects.appserver._private.WODynamicGroup) NSMutableArray(com.webobjects.foundation.NSMutableArray) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOElement(com.webobjects.appserver.WOElement)

Example 10 with WOElement

use of com.webobjects.appserver.WOElement in project wonder-slim by undur.

the class ERXWOSwitchComponent method takeValuesFromRequest.

@Override
public void takeValuesFromRequest(WORequest paramWORequest, WOContext paramWOContext) {
    String name = componentNameInContext(paramWOContext.component());
    String id = _elementNameInContext(name, paramWOContext);
    paramWOContext.appendElementIDComponent(id);
    WOElement localWOElement = _realComponentWithName(name, id, paramWOContext);
    localWOElement.takeValuesFromRequest(paramWORequest, paramWOContext);
    paramWOContext.deleteLastElementIDComponent();
}
Also used : WOElement(com.webobjects.appserver.WOElement)

Aggregations

WOElement (com.webobjects.appserver.WOElement)26 WOHTMLBareString (com.webobjects.appserver._private.WOHTMLBareString)8 Enumeration (java.util.Enumeration)6 WODeclaration (com.webobjects.appserver._private.WODeclaration)4 WODynamicGroup (com.webobjects.appserver._private.WODynamicGroup)4 WOComponent (com.webobjects.appserver.WOComponent)3 NSMutableArray (com.webobjects.foundation.NSMutableArray)3 WOActionResults (com.webobjects.appserver.WOActionResults)2 WOComponentReference (com.webobjects.appserver._private.WOComponentReference)2 WOHTMLCommentString (com.webobjects.appserver._private.WOHTMLCommentString)2 NSArray (com.webobjects.foundation.NSArray)2 WOResponse (com.webobjects.appserver.WOResponse)1 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)1 WODynamicElementCreationException (com.webobjects.appserver._private.WODynamicElementCreationException)1 ERXWOTemplate (er.extensions.components.conditionals.ERXWOTemplate)1 Iterator (java.util.Iterator)1 List (java.util.List)1