Package org.apache.cocoon.xml

Examples of org.apache.cocoon.xml.AttributesImpl


                } else {
                    store = this.basketManager.getBriefcase();
                }

                final Event e = new AddItemEvent(store, ci);
                final AttributesImpl ai = new AttributesImpl();
                String newLink = service.getComponentManager().getLinkService().getLinkURI(e);
                // check for bockmark
                final String bookmark = attr.getValue("bookmark");
                if ( bookmark != null && bookmark.length() > 0) {
                    int pos = newLink.indexOf('?') + 1;
                    final char separator;
                    if ( bookmark.indexOf('?') == -1 ) {
                        separator = '?';
                    } else {
                        separator = '&';
                    }
                    newLink = bookmark + separator + newLink.substring(pos);
                }
                ai.addCDATAAttribute("href", newLink);

                final String linkElementName = this.parameters.getParameter("link-element", this.defaultLinkElement);
                final String linkElementNS = this.parameters.getParameter("link-element-ns", this.defaultLinkElementNS);
                XMLUtils.startElement(this.contentHandler, linkElementNS, linkElementName, ai);
            } catch (ServiceException se) {
                throw new SAXException("Unable to lookup portal service.", se);
            } finally {
                this.manager.release(service);
            }
        } else if ( SHOW_ACTIONS_ELEMENT.equals(name) ) {
            // basket or briefcase
            final List actions;
            final String storeName = (attr.getValue("store") == null ? this.defaultStoreName : attr.getValue("store"));
            if ("basket".equalsIgnoreCase(storeName) )     {
                actions = this.basketManager.getBasketActions();
            } else {
                actions = this.basketManager.getBriefcaseActions();
                }
            final String checkedAction = attr.getValue("checked");
            final Iterator i = actions.iterator();
            AttributesImpl a = new AttributesImpl();
            while ( i.hasNext() ) {
                final BasketManager.ActionInfo current = (ActionInfo) i.next();
                a.addCDATAAttribute("name", current.name);
                if ( current.name.equals(checkedAction) ) {
                    a.addCDATAAttribute("checked", "true");
                }
                XMLUtils.createElement(this.xmlConsumer, "action", a);
                a.clear();
            }
        }
    }
View Full Code Here


        DOMBuilder domBuilder = new DOMBuilder();
        // Start document and "fi:fragment" root element
        domBuilder.startDocument();
        domBuilder.startPrefixMapping(Constants.INSTANCE_PREFIX, Constants.INSTANCE_NS);
        // FIXME: why simply declaring the prefix isn't enough?
        AttributesImpl attr = new AttributesImpl();
        attr.addCDATAAttribute(NamespaceSupport.XMLNS, "fi:", "xmlns:fi", Constants.INSTANCE_NS);
        domBuilder.startElement(Constants.INSTANCE_NS, "fragment", Constants.INSTANCE_PREFIX_COLON + "fragment", attr);
       
        widget.generateSaxFragment(domBuilder, locale);
       
        // End "fi:fragment" element and document
View Full Code Here

            if ( config.rootTag ) {
                XMLUtils.startElement(handler, config.tagName);
            }

            AttributesImpl attributes = new AttributesImpl();
            CompositeLayout tabLayout = (CompositeLayout) layout;

            // selected tab
            Integer data = (Integer) layout.getAspectData(config.aspectName);
            int selected = data.intValue();
           
            // loop over all tabs
            for (int j = 0; j < tabLayout.getSize(); j++) {
                Item tab = tabLayout.getItem(j);
                ChangeAspectDataEvent event = null;

                // open named-item tag
                attributes.clear();
                if ( tab instanceof NamedItem ) {
                    attributes.addCDATAAttribute("name", String.valueOf(((NamedItem)tab).getName()));
                }
                if (j == selected) {
                    attributes.addCDATAAttribute("selected", "true");
                }
                event = new ChangeAspectDataEvent(tabLayout, config.aspectName, new Integer(j));
                attributes.addCDATAAttribute("parameter", service.getComponentManager().getLinkService().getLinkURI(event));

                // add parameters
                final Iterator iter = tab.getParameters().entrySet().iterator();
                while ( iter.hasNext() ) {
                    final Map.Entry entry = (Map.Entry) iter.next();
                    attributes.addCDATAAttribute((String)entry.getKey(), (String)entry.getValue());
                }
               
                XMLUtils.startElement(handler, "named-item", attributes);
                if (j == selected) {
                    this.processLayout(tab.getLayout(), service, handler);
View Full Code Here

            if (tabLayout.getSize() == 0) {
                return;
            }
            TabPreparedConfiguration config =
                (TabPreparedConfiguration) context.getAspectConfiguration();
            AttributesImpl attributes = new AttributesImpl();
            boolean subNav = false;

            // loop over all tabs
            for (int j = 0; j < tabLayout.getSize(); j++) {
                Item tab = tabLayout.getItem(j);

                // open named-item tag
                attributes.clear();
                if (tab instanceof NamedItem) {
                    if (!subNav && !config.childTagName.equals("")) {
                        XMLUtils.startElement(handler, config.childTagName);
                        subNav = true;
                    }
                    attributes.addCDATAAttribute("name",
                        String.valueOf(((NamedItem) tab).getName()));
                    ChangeAspectDataEvent event = new ChangeAspectDataEvent(tabLayout,
                        config.aspectName, new Integer(j));
                    List events = new ArrayList(parentEvents);
                    events.add(event);

                    attributes.addCDATAAttribute("parameter",
                        service.getComponentManager().getLinkService().getLinkURI(events));

                    // add parameters
                    final Iterator iter = tab.getParameters().entrySet().iterator();
                    while (iter.hasNext()) {
                        final Map.Entry entry = (Map.Entry) iter.next();
                        attributes.addCDATAAttribute((String) entry.getKey(),
                            (String) entry.getValue());
                    }

                    XMLUtils.startElement(handler, "named-item", attributes);
View Full Code Here

        Map parameters = item.getParameters();
        if (parameters.size() == 0) {
            XMLUtils.startElement(handler, ITEM_STRING);
        } else {
            AttributesImpl attributes = new AttributesImpl();

      Map.Entry entry;
      for (Iterator iter = parameters.entrySet().iterator(); iter.hasNext();) {
        entry = (Map.Entry) iter.next();
        attributes.addCDATAAttribute((String)entry.getKey(), (String)entry.getValue());
      }
            XMLUtils.startElement(handler, ITEM_STRING, attributes);
        }
        processLayout(layout, service, handler);
        XMLUtils.endElement(handler, ITEM_STRING);
View Full Code Here

    private static final String FIELD_EL = "field";
    private static final String VALUE_EL = "value";
    private static final String VALIDATION_MSG_EL = "validation-message";

    public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
        AttributesImpl fieldAttrs = new AttributesImpl();
        fieldAttrs.addCDATAAttribute("id", getFullyQualifiedId());
        fieldAttrs.addCDATAAttribute("required", String.valueOf(isRequired()));
        contentHandler.startElement(Constants.WI_NS, FIELD_EL, Constants.WI_PREFIX_COLON + FIELD_EL, fieldAttrs);

        if (enteredValue != null || value != null) {
            contentHandler.startElement(Constants.WI_NS, VALUE_EL, Constants.WI_PREFIX_COLON + VALUE_EL, Constants.EMPTY_ATTRS);
            String stringValue;
View Full Code Here

    public void generateSaxFragment(ContentHandler contentHandler, Locale locale, String element) throws SAXException {
        if (getId() == null || getId().equals("")) {
            contentHandler.startElement(Constants.WI_NS, element, Constants.WI_PREFIX_COLON + element, Constants.EMPTY_ATTRS);
        } else {
            AttributesImpl attrs = new AttributesImpl();
            attrs.addCDATAAttribute("id", getFullyQualifiedId());
            contentHandler.startElement(Constants.WI_NS, element, Constants.WI_PREFIX_COLON + element, attrs);
        }
        if (definition != null)
            definition.generateDisplayData(contentHandler);
        // The child widgets
View Full Code Here

    private static final String HEADING_EL = "heading";
    private static final String LABEL_EL = "label";
    private static final String REPEATER_SIZE_EL = "repeater-size";

    public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
        AttributesImpl repeaterAttrs = new AttributesImpl();
        repeaterAttrs.addCDATAAttribute("id", getFullyQualifiedId());
        repeaterAttrs.addCDATAAttribute("size", String.valueOf(getSize()));
        contentHandler.startElement(Constants.WI_NS, REPEATER_EL, Constants.WI_PREFIX_COLON + REPEATER_EL, repeaterAttrs);

        // the repeater's label
        contentHandler.startElement(Constants.WI_NS, LABEL_EL, Constants.WI_PREFIX_COLON + LABEL_EL, Constants.EMPTY_ATTRS);
        definition.generateLabel(contentHandler);
View Full Code Here

    /**
     * Generates a repeater-size element with a size attribute indicating the size of this repeater.
     */
    public void generateSize(ContentHandler contentHandler) throws SAXException {
        AttributesImpl attrs = new AttributesImpl();
        attrs.addCDATAAttribute("id", getFullyQualifiedId());
        attrs.addCDATAAttribute("size", String.valueOf(getSize()));
        contentHandler.startElement(Constants.WI_NS, REPEATER_SIZE_EL, Constants.WI_PREFIX_COLON + REPEATER_SIZE_EL, attrs);
        contentHandler.endElement(Constants.WI_NS, REPEATER_SIZE_EL, Constants.WI_PREFIX_COLON + REPEATER_SIZE_EL);
    }
View Full Code Here

        public void generateLabel(ContentHandler contentHandler) throws SAXException {
            // this widget has no label
        }

        public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
            AttributesImpl rowAttrs = new AttributesImpl();
            rowAttrs.addCDATAAttribute("id", getFullyQualifiedId());
            contentHandler.startElement(Constants.WI_NS, ROW_EL, Constants.WI_PREFIX_COLON + ROW_EL, rowAttrs);
            Iterator widgetIt = widgets.iterator();
            while (widgetIt.hasNext()) {
                Widget widget = (Widget)widgetIt.next();
                widget.generateSaxFragment(contentHandler, locale);
View Full Code Here

TOP

Related Classes of org.apache.cocoon.xml.AttributesImpl

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.