Example usage for org.apache.wicket.markup.html WebComponent WebComponent

List of usage examples for org.apache.wicket.markup.html WebComponent WebComponent

Introduction

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

Prototype

public WebComponent(final String id, final IModel<?> model) 

Source Link

Usage

From source file:org.efaps.ui.wicket.components.editor.EditorPanel.java

License:Apache License

/**
 * @param _wicketId wicketID for this component
 * @param _model model for this componet
 *///from   ww w .  j a  v  a2s  .c  o  m
public EditorPanel(final String _wicketId, final IModel<AbstractUIField> _model) {
    super(_wicketId, _model);

    final WebComponent text = new WebComponent("text", _model) {

        /**
         *
         */
        private static final long serialVersionUID = 1L;

        /**
         * @see org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag)
         * @param _tag
         */
        @Override
        protected void onComponentTag(final ComponentTag _tag) {
            super.onComponentTag(_tag);
            //_tag.put("name", ((UIFormCell) super.getDefaultModelObject()).getName());
            _tag.put("style", "display:none");
        }

        @Override
        public void onComponentTagBody(final MarkupStream _markupStream, final ComponentTag _openTag) {

        }
    };
    this.add(text);
    text.setOutputMarkupId(true);

    final WebComponent editor = new WebComponent("editor", _model) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTag(final ComponentTag _tag) {
            super.onComponentTag(_tag);
            _tag.put("onChange",
                    "document.getElementById('" + text.getMarkupId(true) + "').value=arguments[0];");
        }

        /**
         * @see org.apache.wicket.Component#onComponentTagBody(org.apache.wicket.markup.MarkupStream,
         *      org.apache.wicket.markup.ComponentTag)
         * @param _markupStream
         * @param _openTag
         */
        @Override
        public void onComponentTagBody(final MarkupStream _markupStream, final ComponentTag _openTag) {

        }
    };
    editor.add(new EditorBehavior(null));
    this.add(editor);
}

From source file:org.efaps.ui.wicket.components.menu.PopupMenuPanel.java

License:Apache License

/**
 * @param _wicketId wicketId of this Panel
 * @param _model model for this Panel/*  w ww .j av a  2  s.c om*/
 * @param _idGenerator helper for ids
 * @param _isMenuBarItem part of the main menu bar or not
 * @throws CacheReloadException on error
 */
public PopupMenuPanel(final String _wicketId, final IModel<?> _model, final IdGenerator _idGenerator,
        final boolean _isMenuBarItem) throws CacheReloadException {
    super(_wicketId, _model);
    this.menuBarItem = _isMenuBarItem;
    final UIMenuItem menuItem = (UIMenuItem) super.getDefaultModelObject();

    if (_isMenuBarItem) {
        add(new PopupMenuBarItemBehavior());
    } else {
        add(new PopupMenuItemBehavior());
    }
    add(new WebComponent("label", Model.of(menuItem)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onComponentTagBody(final MarkupStream _markupStream, final ComponentTag _openTag) {
            super.onComponentTagBody(_markupStream, _openTag);
            final UIMenuItem uiItem = (UIMenuItem) getDefaultModelObject();
            final StringBuilder html = new StringBuilder();
            if (PopupMenuPanel.this.menuBarItem && uiItem.getImage() != null) {
                html.append("<img src=\"/..").append(uiItem.getImage()).append("\" class=\"eFapsMenuImage\"/>");
            } else if (!PopupMenuPanel.this.menuBarItem) {
                if (uiItem.getImage() == null) {
                    html.append("<div class=\"eFapsMenuImagePlaceHolder\">").append("&nbsp;</div>");
                } else {
                    html.append("<img src=\"/..").append(uiItem.getImage())
                            .append("\" class=\"eFapsMenuImage\"/>");
                }
            }
            html.append("<span class=\"eFapsMenuLabel\">").append(uiItem.getLabel()).append("</span>");
            replaceComponentTagBody(_markupStream, _openTag, html);
        }
    });
    add(new DropDownMenuPanel("menu", Model.of(menuItem), _idGenerator));
}