Search in sources :

Example 11 with WOElement

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

the class ERXWOSwitchComponent method appendToResponse.

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

Example 12 with WOElement

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

the class ERXWOSwitch method childCaseInContext.

protected WOElement childCaseInContext(WOContext context) {
    Object value = _case.valueInComponent(context.component());
    value = (value == null ? "default" : value);
    WOElement result = _childCases.objectForKey(value);
    if (result == null) {
        result = _childCases.objectForKey("default");
    }
    if (result == null) {
        result = new WOHTMLBareString("");
    }
    return result;
}
Also used : WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOElement(com.webobjects.appserver.WOElement)

Example 13 with WOElement

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

the class AjaxTabbedPanel method findTabs.

/**
 * Looks through the child components to locate the AjaxTabbedPanelTabs that are controlled by this panel.
 * Tabs without an explicit id attributed are assigned a calculated one.
 *
 * @param template the graph of elements passed to the constructor.
 */
private void findTabs(WODynamicGroup template) {
    if (template == null || template.childrenElements() == null)
        return;
    NSArray children = template.childrenElements();
    for (int i = 0; i < children.count(); i++) {
        WOElement child = (WOElement) children.objectAtIndex(i);
        if (child instanceof AjaxTabbedPanelTab) {
            AjaxTabbedPanelTab childTab = (AjaxTabbedPanelTab) child;
            // The tabs need to have an id attribute so we assign one if needed
            if (childTab.id() == null) {
                childTab.setParentId(id);
                childTab.setTabNumber(new WOConstantValueAssociation("_pane_" + tabs.count()));
            }
            tabs.addObject(childTab);
        } else if (child instanceof WODynamicGroup) {
            findTabs((WODynamicGroup) child);
        }
    }
}
Also used : NSArray(com.webobjects.foundation.NSArray) WODynamicGroup(com.webobjects.appserver._private.WODynamicGroup) WOConstantValueAssociation(com.webobjects.appserver._private.WOConstantValueAssociation) WOElement(com.webobjects.appserver.WOElement)

Example 14 with WOElement

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

the class AjaxAutoComplete method handleRequest.

/**
 * Handles the Ajax request. Checks for the form value in the edit field,
 * pushes it up to the parent and pulls the "list" binding. The parent is
 * responsible for returning a list with some items that match the current value.
 */
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
    // String inputString = request.contentString();
    String fieldValue = context.request().stringFormValueForKey(fieldName);
    setValueForBinding(fieldValue, "value");
    WOResponse response = AjaxUtils.createResponse(request, context);
    response.appendContentString("<ul>");
    int maxItems = maxItems();
    int itemsCount = 0;
    Object values = valueForBinding("list");
    WOElement child = _childTemplate();
    boolean hasItem = hasBinding("item");
    if (values instanceof NSArray) {
        for (Enumeration valueEnum = ((NSArray) values).objectEnumerator(); valueEnum.hasMoreElements() && itemsCount++ < maxItems; ) {
            appendItemToResponse(valueEnum.nextElement(), child, hasItem, response, context);
        }
    } else if (values instanceof List) {
        for (Iterator iter = ((List) values).iterator(); iter.hasNext() && itemsCount++ < maxItems; ) {
            appendItemToResponse(iter.next(), child, hasItem, response, context);
        }
    } else if (values instanceof Object[]) {
        Object[] array = (Object[]) values;
        for (int i = 0; i < array.length && i < maxItems; i++) {
            appendItemToResponse(array[i], child, hasItem, response, context);
        }
    } else if (values != null) {
        log.warn("Unsupported class type for list: {}", values.getClass().getCanonicalName());
    }
    response.appendContentString("</ul>");
    return response;
}
Also used : Enumeration(java.util.Enumeration) NSArray(com.webobjects.foundation.NSArray) Iterator(java.util.Iterator) List(java.util.List) WOResponse(com.webobjects.appserver.WOResponse) WOElement(com.webobjects.appserver.WOElement)

Example 15 with WOElement

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

the class WOHTMLWebObjectTag method dynamicElement.

public WOElement dynamicElement(NSDictionary nsdictionary, NSArray nsarray) throws WOHelperFunctionDeclarationFormatException, ClassNotFoundException {
    String s = name();
    WOElement woelement = template();
    WODeclaration wodeclaration = (WODeclaration) nsdictionary.objectForKey(s);
    return _elementWithDeclaration(wodeclaration, s, woelement, nsarray);
}
Also used : WODeclaration(com.webobjects.appserver._private.WODeclaration) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) 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