Example usage for org.apache.wicket.markup ComponentTag ComponentTag

List of usage examples for org.apache.wicket.markup ComponentTag ComponentTag

Introduction

In this page you can find the example usage for org.apache.wicket.markup ComponentTag ComponentTag.

Prototype

public ComponentTag(final ComponentTag tag) 

Source Link

Document

Constructor

Usage

From source file:com.myamamoto.wicket.misc.behavior.AppendErrorClassOnErrorBehaviorTest.java

License:Apache License

@Before
public void setUp() {
    this.tester = new WicketTester();
    this.behavior = new AppendErrorClassOnErrorBehavior();
    this.component = new WebComponent("component");
    this.componentTag = new ComponentTag(new XmlTag());
}

From source file:org.efaps.ui.wicket.components.LabelComponent.java

License:Apache License

/**
 * Must be overwritten so that no replacing of html tags is done.
 *
 * @see org.apache.wicket.Component#onComponentTagBody(org.apache.wicket.markup.MarkupStream,
 *      org.apache.wicket.markup.ComponentTag)
 *
 * @param _markupStream MarkupStream// w  ww .j av  a2 s. c o m
 * @param _openTag Tag
 */
@Override
public void onComponentTagBody(final MarkupStream _markupStream, final ComponentTag _openTag) {
    setEscapeModelStrings(false);
    String value = getDefaultModelObjectAsString(getDefaultModelObject());
    // if the value contains the EFAPSTMPTAG all tags from this component
    // will be moved to the subcomponent
    if (value != null && value.contains(IUserInterface.EFAPSTMPTAG)) {
        final StringBuilder tagBldr = new StringBuilder();
        final List<? extends Behavior> behaviors = getBehaviors();
        final ComponentTag tmpTag = new ComponentTag(_openTag);
        for (final Behavior behavior : behaviors) {
            behavior.onComponentTag(this, tmpTag);
        }
        final IValueMap map = tmpTag.getAttributes();
        for (final Entry<String, Object> entry : map.entrySet()) {
            final String key = entry.getKey();
            if (!"wicket:id".equals(key)) {
                tagBldr.append(" ").append(key).append("=\"").append(entry.getValue()).append("\" ");
            }
        }
        // if no id is given add the id here
        if (!map.containsKey("id")) {
            tagBldr.append(" id=\"").append(getMarkupId()).append("\" ");
        }
        value = value.replace(IUserInterface.EFAPSTMPTAG, tagBldr);
    }
    super.replaceComponentTagBody(_markupStream, _openTag, value);
}