Example usage for org.apache.wicket.behavior Behavior onComponentTag

List of usage examples for org.apache.wicket.behavior Behavior onComponentTag

Introduction

In this page you can find the example usage for org.apache.wicket.behavior Behavior onComponentTag.

Prototype

public void onComponentTag(Component component, ComponentTag tag) 

Source Link

Document

Called any time a component that has this behavior registered is rendering the component tag.

Usage

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//from   w  w  w . ja va  2s  .com
 * @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);
}

From source file:org.hippoecm.frontend.dialog.ButtonWrapper.java

License:Apache License

public void setEnabled(boolean isset) {
    enabled = isset;/*from   ww w  .  j  a  v a  2 s . com*/
    if (button != null && WebApplicationHelper.isPartOfPage(button)) {
        button.setEnabled(isset);
        if (ajax) {
            AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
            if (target != null) {
                if (!isset) {
                    renderAttribute(target, "disabled", "disabled");
                } else {
                    target.appendJavaScript(
                            "Wicket.$('" + button.getMarkupId() + "').removeAttribute('disabled')");
                    for (Behavior behavior : button.getBehaviors()) {
                        ComponentTag tag = new ComponentTag("button", XmlTag.TagType.OPEN_CLOSE);
                        behavior.onComponentTag(button, tag);
                        behavior.renderHead(button, target.getHeaderResponse());

                        for (Map.Entry<String, Object> entry : tag.getAttributes().entrySet()) {
                            renderAttribute(target, entry.getKey(), entry.getValue());
                        }
                    }
                }
            }
        }
    }
}

From source file:org.wicketstuff.minis.behavior.CompositeBehavior.java

License:Apache License

/**
 * {@inheritDoc}/*from w  w w  . j  ava2 s .  co  m*/
 */
@Override
public void onComponentTag(final Component aComponent, final ComponentTag aTag) {
    for (final Behavior behavior : behaviors_)
        behavior.onComponentTag(aComponent, aTag);
}