Example usage for org.apache.wicket.markup.html WebMarkupContainer getMarkupId

List of usage examples for org.apache.wicket.markup.html WebMarkupContainer getMarkupId

Introduction

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

Prototype

public String getMarkupId() 

Source Link

Document

Retrieves id by which this component is represented within the markup.

Usage

From source file:com.comsysto.insight.component.HighchartsPanel.java

License:Apache License

public HighchartsPanel(String id, final Highchart highcharts) {
    super(id);/*from  w w w. j a  va2  s  . com*/

    final WebMarkupContainer chartDiv = new WebMarkupContainer("highchart");
    chartDiv.setOutputMarkupId(true);

    add(chartDiv);

    // store ID into chart.renderTo
    highcharts.getChart().setRenderTo(chartDiv.getMarkupId());

    /*
    * we inject the script in the component body and not as a header contribution
    * because the script needs to be called each time the component is refreshed using wicket
    * ajax support.
    */
    add(new Label("script", new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            StringBuffer js = new StringBuffer();
            js.append("var ").append(chartDiv.getMarkupId()).append(";\n");
            js.append("$(document).ready(function() {\n");
            js.append(chartDiv.getMarkupId());
            js.append(" = new Highcharts.Chart(");

            js.append(highcharts.toJson());

            js.append(" ); }); ");

            return js.toString();
        }
    }).setEscapeModelStrings(false));
}

From source file:com.doculibre.constellio.wicket.panels.facets.FacetFoldableSectionPanel.java

License:Open Source License

@Override
protected WebMarkupContainer newToggleLink(String id) {
    WebMarkupContainer jsToggleLink = new WebMarkupContainer(id);
    jsToggleLink.add(new AttributeModifier("onclick", true, new LoadableDetachableModel() {
        @Override//from   ww  w.j  av a2s.  co  m
        protected Object load() {
            WebMarkupContainer foldableSectionContainer = getFoldableSectionContainer();
            Image toggleImg = getToggleImg();
            String foldableSectionContainerId = foldableSectionContainer.getMarkupId();
            String toggleImgId = toggleImg.getMarkupId();
            CharSequence openedImgURL = urlFor(OPENED_IMG_RESOURCE_REFERENCE);
            CharSequence closedImgURL = urlFor(CLOSED_IMG_RESOURCE_REFERENCE);
            String cookieName = getCookieName();
            // function toggleSection(foldableSectionContainerId, toggleImgId, openedImgURL, closedImgURL,
            // cookieName)
            StringBuffer js = new StringBuffer();
            js.append("toggleSection('");
            js.append(foldableSectionContainerId);
            js.append("', '");
            js.append(toggleImgId);
            js.append("', '");
            js.append(openedImgURL);
            js.append("', '");
            js.append(closedImgURL);
            js.append("', '");
            js.append(cookieName);
            js.append("')");
            return js;
        }
    }));
    return jsToggleLink;
}

From source file:com.evolveum.midpoint.web.component.accordion.Accordion.java

License:Apache License

@Override
public void renderHead(IHeaderResponse response) {
    super.renderHead(response);

    response.render(// w  w  w .  j  av a2  s  .  c o  m
            JavaScriptHeaderItem.forReference(new PackageResourceReference(Accordion.class, "Accordion.js")));
    response.render(CssHeaderItem.forReference(new PackageResourceReference(Accordion.class, "Accordion.css")));

    WebMarkupContainer parent = (WebMarkupContainer) get("parent");
    response.render(OnDomReadyHeaderItem.forScript("createAccordion('" + parent.getMarkupId() + "',"
            + getExpanded() + "," + getMultipleSelect() + "," + getOpenedPanel() + ")"));
}

From source file:com.evolveum.midpoint.web.component.message.FeedbackMessagePanel.java

License:Apache License

private void initLayout(final IModel<FeedbackMessage> message) {
    WebMarkupContainer messageContainer = new WebMarkupContainer("messageContainer");
    messageContainer.setOutputMarkupId(true);
    messageContainer.add(new AttributeAppender("class", new LoadableModel<String>() {
        @Override//from  www . j av a  2  s. c  o m
        protected String load() {
            return getLabelCss(message);
        }
    }, " "));
    messageContainer.add(new AttributeModifier("title", new LoadableModel<String>() {

        @Override
        protected String load() {
            return getString("feedbackMessagePanel.message." + createMessageTooltip(message));
        }
    }));
    add(messageContainer);
    Label label = new Label("message", new LoadableModel<String>(false) {

        @Override
        protected String load() {
            return getTopMessage(message);
        }
    });
    messageContainer.add(label);
    WebMarkupContainer topExceptionContainer = new WebMarkupContainer("topExceptionContainer");
    messageContainer.add(topExceptionContainer);
    WebMarkupContainer content = new WebMarkupContainer("content");
    if (message.getObject().getMessage() instanceof OpResult) {

        OpResult result = (OpResult) message.getObject().getMessage();
        xml = result.getXml();
        export(content, new Model<String>(xml));

        ListView<OpResult> subresults = new ListView<OpResult>("subresults", createSubresultsModel(message)) {

            @Override
            protected void populateItem(final ListItem<OpResult> item) {
                item.add(new AttributeAppender("class",
                        OperationResultPanel.createMessageLiClass(item.getModel()), " "));
                item.add(new AttributeModifier("title", new LoadableModel<String>() {

                    @Override
                    protected String load() {
                        return getString("feedbackMessagePanel.message."
                                + OperationResultPanel.createMessageTooltip(item.getModel()).getObject());
                    }
                }));
                item.add(new OperationResultPanel("subresult", item.getModel()));
            }
        };
        content.add(subresults);
        content.add(new AttributeAppender("class", new LoadableModel<String>(false) {

            @Override
            protected String load() {
                return getDetailsCss(new PropertyModel<OpResult>(message, "message"));
            }
        }, " "));
    } else {
        content.setVisible(false);
        topExceptionContainer.setVisibilityAllowed(false);
    }
    content.setMarkupId(messageContainer.getMarkupId() + "_content");
    add(content);

    WebMarkupContainer operationPanel = new WebMarkupContainer("operationPanel");
    topExceptionContainer.add(operationPanel);

    operationPanel.add(new Label("operation", new LoadableModel<String>() {

        @Override
        protected String load() {
            OpResult result = (OpResult) message.getObject().getMessage();

            String resourceKey = OperationResultPanel.OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
            return getPage().getString(resourceKey, null, resourceKey);
        }
    }));

    WebMarkupContainer countPanel = new WebMarkupContainer("countPanel");
    countPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            OpResult result = (OpResult) message.getObject().getMessage();
            return result.getCount() > 1;
        }
    });
    countPanel.add(new Label("count", new PropertyModel<String>(message, "message.count")));
    operationPanel.add(countPanel);

    ListView<Param> params = new ListView<Param>("params",
            OperationResultPanel.createParamsModel(new PropertyModel<OpResult>(message, "message"))) {

        @Override
        protected void populateItem(ListItem<Param> item) {
            item.add(new Label("paramName", new PropertyModel<Object>(item.getModel(), "name")));
            item.add(new Label("paramValue", new PropertyModel<Object>(item.getModel(), "value")));
        }
    };
    topExceptionContainer.add(params);

    ListView<Context> contexts = new ListView<Context>("contexts",
            OperationResultPanel.createContextsModel(new PropertyModel<OpResult>(message, "message"))) {
        @Override
        protected void populateItem(ListItem<Context> item) {
            item.add(new Label("contextName", new PropertyModel<Object>(item.getModel(), "name")));
            item.add(new Label("contextValue", new PropertyModel<Object>(item.getModel(), "value")));
        }
    };
    topExceptionContainer.add(contexts);

    /*
       * WebMarkupContainer countLi = new WebMarkupContainer("countLi");
     * countLi.add(new VisibleEnableBehaviour() {
     * 
     * @Override public boolean isVisible() { OpResult result = (OpResult)
     * message.getObject().getMessage(); return result.getCount() > 1; } });
     * content.add(countLi); countLi.add(new Label("count", new
     * PropertyModel<String>(message, "message.count")));
     */

    initExceptionLayout(content, topExceptionContainer, message);

    content.add(new Label("collapseAll", new LoadableModel<String>() {

        @Override
        protected String load() {
            return getString("feedbackMessagePanel.collapseAll");
        }
    }));
    content.add(new Label("expandAll", new LoadableModel<String>() {

        @Override
        protected String load() {
            return getString("feedbackMessagePanel.expandAll");
        }
    }));
}

From source file:com.evolveum.midpoint.web.component.message.FeedbackMessagePanel.java

License:Apache License

private void initExceptionLayout(WebMarkupContainer content, WebMarkupContainer topExceptionContainer,
        final IModel<FeedbackMessage> message) {
    WebMarkupContainer exception = new WebMarkupContainer("exception") {

        @Override/*from  w w  w.  ja v  a  2s.  c  o m*/
        public boolean isVisible() {
            return isExceptionVisible(message);
        }
    };
    topExceptionContainer.add(exception);
    exception.add(new MultiLineLabel("exceptionMessage",
            new PropertyModel<String>(message, "message.exceptionMessage")));

    WebMarkupContainer errorStackContainer = new WebMarkupContainer("errorStackContainer") {
        @Override
        public boolean isVisible() {
            return isExceptionVisible(message);
        }
    };
    content.add(errorStackContainer);

    WebMarkupContainer errorStack = new WebMarkupContainer("errorStack");
    errorStack.setOutputMarkupId(true);
    errorStackContainer.add(errorStack);

    // export(errorStackContainer, new PropertyModel<String>(message,
    // "message.exceptionsStackTrace"));

    WebMarkupContainer errorStackContent = new WebMarkupContainer("errorStackContent");
    errorStackContent.setMarkupId(errorStack.getMarkupId() + "_content");
    errorStackContainer.add(errorStackContent);

    errorStackContent.add(new MultiLineLabel("exceptionStack",
            new PropertyModel<String>(message, "message.exceptionsStackTrace")));
}

From source file:com.evolveum.midpoint.web.component.message.OperationResultPanel.java

License:Apache License

private void initLayout(final IModel<OpResult> model) {
    WebMarkupContainer operationPanel = new WebMarkupContainer("operationPanel");
    operationPanel.setOutputMarkupId(true);
    add(operationPanel);/* w w  w. j a v  a 2 s  .co m*/
    Label operation = new Label("operation", new LoadableModel<Object>() {

        @Override
        protected Object load() {
            OpResult result = model.getObject();

            String resourceKey = OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
            return getPage().getString(resourceKey, null, resourceKey);
        }
    });
    operation.setOutputMarkupId(true);
    operationPanel.add(operation);
    operationPanel.add(initCountPanel(model));

    WebMarkupContainer arrow = new WebMarkupContainer("arrow");
    arrow.add(new AttributeAppender("class", createArrowClass(model), " "));
    arrow.setMarkupId(operationPanel.getMarkupId() + "_arrow");
    add(arrow);

    WebMarkupContainer operationContent = new WebMarkupContainer("operationContent");
    operationContent.setMarkupId(operationPanel.getMarkupId() + "_content");
    add(operationContent);

    operationContent.add(new Label("message", new PropertyModel<String>(model, "message")));

    initParams(operationContent, model);
    initContexts(operationContent, model);
    //initCount(operationContent, model);
    initExceptionLayout(operationContent, model);

}

From source file:com.evolveum.midpoint.web.component.message.OperationResultPanel.java

License:Apache License

private void initExceptionLayout(WebMarkupContainer operationContent, final IModel<OpResult> model) {
    WebMarkupContainer exception = new WebMarkupContainer("exception") {

        @Override//w ww .  j  av  a  2s  .  c om
        public boolean isVisible() {
            OpResult result = model.getObject();
            return StringUtils.isNotEmpty(result.getExceptionMessage())
                    || StringUtils.isNotEmpty(result.getExceptionsStackTrace());
        }
    };
    operationContent.add(exception);
    exception.add(new MultiLineLabel("exceptionMessage", new PropertyModel<String>(model, "exceptionMessage")));

    WebMarkupContainer errorStack = new WebMarkupContainer("errorStack");
    errorStack.setOutputMarkupId(true);
    exception.add(errorStack);

    WebMarkupContainer errorStackContent = new WebMarkupContainer("errorStackContent");
    errorStackContent.setMarkupId(errorStack.getMarkupId() + "_content");
    exception.add(errorStackContent);

    errorStackContent.add(
            new MultiLineLabel("exceptionStack", new PropertyModel<String>(model, "exceptionsStackTrace")));
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.LimitationsEditorDialog.java

License:Apache License

private void initLimitationBody(final WebMarkupContainer body, ListItem<PropertyLimitationsTypeDto> item) {
    CheckFormGroup schema = new CheckFormGroup(ID_LAYER_SCHEMA,
            new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_SCHEMA),
            createStringResource("LimitationsEditorDialog.label.schema"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    schema.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(schema);//from www.j  a  va  2  s. c  o  m

    CheckFormGroup model = new CheckFormGroup(ID_LAYER_MODEL,
            new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_MODEL),
            createStringResource("LimitationsEditorDialog.label.model"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    model.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(model);

    CheckFormGroup presentation = new CheckFormGroup(ID_LAYER_PRESENTATION,
            new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_PRESENTATION),
            createStringResource("LimitationsEditorDialog.label.presentation"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    presentation.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(presentation);

    ThreeStateBooleanPanel add = new ThreeStateBooleanPanel(ID_ACCESS_ADD,
            new PropertyModel<Boolean>(item.getModelObject(),
                    PropertyLimitationsTypeDto.F_LIMITATION + ".access.add"),
            "LimitationsEditorDialog.allow", "LimitationsEditorDialog.inherit", "LimitationsEditorDialog.deny",
            null);
    body.add(add);

    ThreeStateBooleanPanel read = new ThreeStateBooleanPanel(ID_ACCESS_READ,
            new PropertyModel<Boolean>(item.getModelObject(),
                    PropertyLimitationsTypeDto.F_LIMITATION + ".access.read"),
            "LimitationsEditorDialog.allow", "LimitationsEditorDialog.inherit", "LimitationsEditorDialog.deny",
            null);
    body.add(read);

    ThreeStateBooleanPanel modify = new ThreeStateBooleanPanel(ID_ACCESS_MODIFY,
            new PropertyModel<Boolean>(item.getModelObject(),
                    PropertyLimitationsTypeDto.F_LIMITATION + ".access.modify"),
            "LimitationsEditorDialog.allow", "LimitationsEditorDialog.inherit", "LimitationsEditorDialog.deny",
            null);
    body.add(modify);

    TextFormGroup minOccurs = new TextFormGroup(ID_MIN_OCCURS,
            new PropertyModel<String>(item.getModelObject(),
                    PropertyLimitationsTypeDto.F_LIMITATION + ".minOccurs"),
            createStringResource("LimitationsEditorDialog.label.minOccurs"),
            "SchemaHandlingStep.limitations.tooltip.minOccurs", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    minOccurs.getField().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(minOccurs);

    TextFormGroup maxOccurs = new TextFormGroup(ID_MAX_OCCURS,
            new PropertyModel<String>(item.getModelObject(),
                    PropertyLimitationsTypeDto.F_LIMITATION + ".maxOccurs"),
            createStringResource("LimitationsEditorDialog.label.maxOccurs"),
            "SchemaHandlingStep.limitations.tooltip.maxOccurs", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    maxOccurs.getField().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(maxOccurs);

    CheckFormGroup ignore = new CheckFormGroup(ID_IGNORE,
            new PropertyModel<Boolean>(item.getModelObject(),
                    PropertyLimitationsTypeDto.F_LIMITATION + ".ignore"),
            createStringResource("LimitationsEditorDialog.label.ignore"),
            "SchemaHandlingStep.limitations.tooltip.ignore", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    ignore.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(ignore);

    Label layersTooltip = new Label(ID_T_LAYERS);
    layersTooltip.add(new InfoTooltipBehavior(true) {

        @Override
        public String getModalContainer(Component component) {
            return body.getMarkupId();
        }
    });
    body.add(layersTooltip);

    Label propertyTooltip = new Label(ID_T_PROPERTY);
    propertyTooltip.add(new InfoTooltipBehavior(true) {

        @Override
        public String getModalContainer(Component component) {
            return body.getMarkupId();
        }
    });
    body.add(propertyTooltip);
}

From source file:com.google.code.jqwicket.ui.cloudzoom.CloudZoomImagePanel.java

License:Apache License

@SuppressWarnings("unchecked")
public CloudZoomImagePanel(String id, final CloudZoomOptions options) {
    super(id);//  ww w . jav a 2  s .  c  o  m

    add(new CloudZoomBehavior(options));

    // add default zoom image
    final CloudZoomImage img = options.getImage();
    final WebMarkupContainer bigImage = this.newCloudZoomLink("cloudZoom-bigImage", img, getDefaultCssClass(),
            Utils.substringBetween(String.valueOf(options), "{", "}"));
    bigImage.add(this.newCloudZoomImage("cloudZoom-smallImage", img.getSmallImageUrl(), img.getImageAlt(),
            img.getImageTitle()));
    add(bigImage);

    // add gallery images
    add(new ListView<CloudZoomGalleryImage>("gallery-repeater",
            options.hasGalleryImages() ? Arrays.asList(options.getGalleryImages()) : Collections.EMPTY_LIST) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<CloudZoomGalleryImage> item) {
            final CloudZoomGalleryImage img = item.getModelObject();

            WebMarkupContainer link = newCloudZoomLink("thumbnail-bigImage", img, getGalleryCssClass(),
                    new StringBuffer().append("useZoom: ").append(Utils.quote(bigImage.getMarkupId()))
                            .append(", smallImage:").append(Utils.quote(img.getSmallImageUrl())));

            link.add(newCloudZoomImage("thumbnail-smallImage",
                    img.hasThumbnailUrl() ? img.getThumbnailUrl() : img.getSmallImageUrl(), null, null));

            item.add(link);

        }

        @Override
        public boolean isVisible() {
            return options.hasGalleryImages();
        }
    });
}

From source file:com.norconex.commons.wicket.markup.html.chart.jqplot.PlotPanel.java

License:Apache License

public PlotPanel(String id, PlotData plotData, boolean minified) {
    super(id);/*from  w ww.ja  v a2 s  .  c  om*/
    setOutputMarkupId(true);

    WebMarkupContainer plotDiv = new WebMarkupContainer("plot");
    plotDiv.setOutputMarkupId(true);
    add(plotDiv);
    String plotId = plotDiv.getMarkupId();

    //XXX hack to get minified version should be done better
    if (minified) {
        AxisOptions xaxis = plotData.getOptions().getAxes().getXaxis();
        Integer val = xaxis.getNumberTicks();
        int numberTicks = 0;
        if (val != null) {
            numberTicks = val;
        }
        if (numberTicks > 0) {
            numberTicks = (int) Math.ceil((float) numberTicks / 2f);
        }
        xaxis.setNumberTicks(numberTicks);
    }

    String code = "";
    if (plotData != null) {
        //--- Options ---
        String options = "{}";
        if (plotData.getOptions() != null) {
            options = plotData.getOptions().toString();
        }
        //--- Series ---
        String series = "[]";
        if (plotData.getSeries() != null) {
            series = "[" + StringUtils.join(plotData.getSeries(), ", ") + "]";
        }
        //--- pre/post JS ---
        String preJs = plotData.getPreJavascript();
        if (preJs == null) {
            preJs = StringUtils.EMPTY;
        }
        String postJs = plotData.getPostJavascript();
        if (postJs == null) {
            postJs = StringUtils.EMPTY;
        }

        //--- Plot Code ---
        code = "$(document).ready(function(){" + preJs + "  $.jqplot.config.enablePlugins = true;"
                + "  var plot = $.jqplot('" + plotId + "', " + series + ", " + options + ");"
                + "  $(window).resize(function() {" + "    if (plot) { "
                + "      $.each(plot.series, function(index, series) {" + "        series.barWidth = undefined;"
                + "      });" + "      plot.replot();" + "    }" + "  });" + postJs + "});";
    }
    Label script = new Label("script", code);
    script.setEscapeModelStrings(false);
    addOrReplace(script);
}