Search in sources :

Example 11 with IValueMap

use of org.apache.wicket.util.value.IValueMap in project wicket by apache.

the class AbstractOptions method onComponentTag.

/**
 * {@inheritDoc}
 */
@Override
protected void onComponentTag(final ComponentTag tag) {
    checkComponentTag(tag, "select");
    super.onComponentTag(tag);
    IValueMap attrs = tag.getAttributes();
    attrs.put("multiple", "multiple");
    attrs.put("size", getPalette().getRows());
    if (!palette.isPaletteEnabled()) {
        attrs.put("disabled", "disabled");
    }
    avoidAjaxSerialization();
}
Also used : IValueMap(org.apache.wicket.util.value.IValueMap)

Example 12 with IValueMap

use of org.apache.wicket.util.value.IValueMap in project wicket by apache.

the class XmlTag method toXmlString.

/**
 * Assuming some attributes have been changed, toXmlString() rebuilds the String on based on the
 * tags informations.
 *
 * @param attributeToBeIgnored
 * @return A xml string matching the tag
 */
public CharSequence toXmlString(final String attributeToBeIgnored) {
    final AppendingStringBuffer buffer = new AppendingStringBuffer();
    buffer.append('<');
    if (type == TagType.CLOSE) {
        buffer.append('/');
    }
    if (namespace != null) {
        buffer.append(namespace);
        buffer.append(':');
    }
    buffer.append(name);
    final IValueMap attributes = getAttributes();
    if (attributes.size() > 0) {
        final Iterator<String> iterator = attributes.keySet().iterator();
        for (; iterator.hasNext(); ) {
            final String key = iterator.next();
            if ((key != null) && ((attributeToBeIgnored == null) || !key.equalsIgnoreCase(attributeToBeIgnored))) {
                buffer.append(' ');
                buffer.append(key);
                CharSequence value = getAttribute(key);
                // Attributes without values are possible, e.g. 'disabled'
                if (value != null) {
                    buffer.append("=\"");
                    value = Strings.escapeMarkup(value);
                    buffer.append(value);
                    buffer.append('"');
                }
            }
        }
    }
    if (type == TagType.OPEN_CLOSE) {
        buffer.append('/');
    }
    buffer.append('>');
    return buffer;
}
Also used : AppendingStringBuffer(org.apache.wicket.util.string.AppendingStringBuffer) IValueMap(org.apache.wicket.util.value.IValueMap)

Example 13 with IValueMap

use of org.apache.wicket.util.value.IValueMap in project wicket by apache.

the class WicketLinkTagHandler method analyzeAutolinkCondition.

/**
 * Analyze the tag. If return value == true, a autolink component will be created.
 * <p>
 * Subclass analyzeAutolinkCondition() to implement you own implementation and register the new
 * tag handler with the markup parser through Application.newMarkupParser().
 *
 * @param tag
 *            The current tag being parsed
 * @return If true, tag will become auto-component
 */
protected boolean analyzeAutolinkCondition(final ComponentTag tag) {
    if (tag.getId() == null) {
        IValueMap attributes = tag.getAttributes();
        String ref = attributes.getString("href");
        if (checkRef(ref)) {
            return true;
        }
        ref = attributes.getString("src");
        if (checkRef(ref)) {
            return true;
        }
    }
    return false;
}
Also used : IValueMap(org.apache.wicket.util.value.IValueMap)

Example 14 with IValueMap

use of org.apache.wicket.util.value.IValueMap in project wicket by apache.

the class WicketNamespaceHandler method determineWicketNamespace.

/**
 * Determine wicket namespace from xmlns:wicket or xmlns:wicket="http://wicket.apache.org"
 *
 * @param tag
 * @return Wicket namespace
 */
private String determineWicketNamespace(final ComponentTag tag) {
    // For all tags attributes
    final IValueMap attributes = tag.getAttributes();
    for (Map.Entry<String, Object> entry : attributes.entrySet()) {
        // Find attributes with namespace "xmlns"
        final String attributeName = entry.getKey();
        if (attributeName.startsWith(XMLNS)) {
            final String xmlnsUrl = (String) entry.getValue();
            // If Wicket relevant ...
            if ((xmlnsUrl == null) || (xmlnsUrl.trim().length() == 0) || xmlnsUrl.startsWith(WICKET_URI)) {
                // Set the Wicket namespace for wicket tags (e.g.
                // <wicket:panel>) and attributes (e.g. wicket:id)
                final String namespace = attributeName.substring(XMLNS.length());
                if (Application.get().getMarkupSettings().getStripWicketTags()) {
                    attributes.remove(attributeName);
                    // Make sure the parser knows it has been changed
                    tag.setModified(true);
                }
                return namespace;
            }
        }
    }
    return null;
}
Also used : IValueMap(org.apache.wicket.util.value.IValueMap) Map(java.util.Map) IValueMap(org.apache.wicket.util.value.IValueMap)

Aggregations

IValueMap (org.apache.wicket.util.value.IValueMap)14 Map (java.util.Map)3 DebugSettings (org.apache.wicket.settings.DebugSettings)2 IConverter (org.apache.wicket.util.convert.IConverter)2 Serializable (java.io.Serializable)1 MarkupException (org.apache.wicket.markup.MarkupException)1 WicketTag (org.apache.wicket.markup.WicketTag)1 AppendingStringBuffer (org.apache.wicket.util.string.AppendingStringBuffer)1