Example usage for org.apache.wicket Component getMarkupId

List of usage examples for org.apache.wicket Component getMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket Component getMarkupId.

Prototype

public String getMarkupId() 

Source Link

Document

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

Usage

From source file:org.cast.isi.page.ISIStatelessPage.java

License:Open Source License

private void checkIfPageStateless(Page p) {
    if (!p.isPageStateless()) {
        // find out why
        final List<Component> statefulComponents = new ArrayList<Component>();
        p.visitChildren(Component.class, new IVisitor<Component, Void>() {
            public void component(Component component, IVisit<Void> visit) {
                if (!component.isStateless()) {
                    statefulComponents.add(component);
                }/*from w  w  w .  java2 s.co  m*/
            }
        });

        String message = "Whoops! this page is no longer stateless";
        if (statefulComponents.size() > 0) {
            message += " - the reason is that it contains the following stateful components: ";
            for (Component c : statefulComponents) {
                message += "\n" + c.getMarkupId() + "[" + c.getClass().getCanonicalName() + "]";
            }
        }
        log.warn(message);
    }

}

From source file:org.cast.isi.panel.ResponseFeedbackPanel.java

License:Open Source License

public void setCallingButton(Component callingButton) {
    this.callingButton = callingButton;
    getSidebarDialog().setVerticalReferencePointId(callingButton.getMarkupId());
}

From source file:org.cdlflex.ui.markup.html.dialog.DialogOpenLink.java

License:Apache License

@Override
protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    if (isLinkEnabled()) {
        Component component = getDialog();

        tag.put("data-toggle", "modal");
        if (component != null) {
            tag.put("data-target", "#" + component.getMarkupId());
        }/*from   ww  w.j  a  v a 2s .c  om*/
    }
}

From source file:org.cipango.ims.oam.util.HideableLink.java

License:Apache License

public HideableLink(String id, Component parent) {
    super(id);/*from w  ww . j  ava 2  s.  c o m*/
    parent.setOutputMarkupId(true);
    _markupId = parent.getMarkupId();
    setOutputMarkupId(true);
}

From source file:org.dcm4chee.web.common.behaviours.FocusOnLoadBehaviour.java

License:LGPL

private String getJavaScriptString(Component c) {
    return "self.focus();var elem=document.getElementById('" + c.getMarkupId() + "');elem.focus()";
}

From source file:org.dcm4chee.web.common.markup.modal.AutoOpenModalWindow.java

License:LGPL

public void renderHead(HtmlHeaderContainer container) {
    super.renderHead(container);
    if (needAutoOpen() && !isShown()) {
        Component c = this.get("content:close");
        container.getHeaderResponse().renderOnLoadJavascript(
                "self.focus();var elem=document.getElementById('" + c.getMarkupId() + "');elem.focus()");
    }/*from   w w w.  j  a  v a 2 s.  c  om*/
    container.getHeaderResponse().renderOnDomReadyJavascript("Wicket.Window.unloadConfirmation = false");
}

From source file:org.dcm4chee.wizard.common.behavior.FocusOnLoadBehavior.java

License:LGPL

private String getJavaScriptString(Component component) {
    return "self.focus();var elem=document.getElementById('" + component.getMarkupId() + "');elem.focus()";
}

From source file:org.devgateway.toolkit.forms.wicket.behaviors.JavascriptCallbackAjaxBehavior.java

License:Open Source License

@Override
public void renderHead(final Component component, final IHeaderResponse response) {
    Map<String, Object> map = new HashMap<>();
    map.put("callbackUrl", getCallbackUrl().toString());
    map.put("args", getCallbackArguments());
    map.put("componentMarkupId", component.getMarkupId());

    try {/*  w ww.  j  a  va2  s .c  om*/
        if (scriptTemplate != null) {
            OnDomReadyHeaderItem onDomReadyHeaderItem = OnDomReadyHeaderItem
                    .forScript(scriptTemplate.asString(map));
            scriptTemplate.close();
            response.render(onDomReadyHeaderItem);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.devproof.portal.core.module.common.component.ValidationDisplayBehaviour.java

License:Apache License

private void printErrorMessage(CharSequence msg, Component componentWithError) {
    PackagedTextTemplate template = new PackagedTextTemplate(ValidationDisplayBehaviour.class,
            "ValidationDisplayBehaviour.html");
    Map<String, Object> variables = new MiniMap<String, Object>(4);
    variables.put("message", msg);
    variables.put("imageUrl", componentWithError.urlFor(ERRORHINT_IMAGE_REF));
    variables.put("imageId", componentWithError.getMarkupId() + "Image");
    variables.put("popupId", componentWithError.getMarkupId() + "Popup");
    componentWithError.getResponse().write(template.asString(variables));
}

From source file:org.efaps.ui.wicket.behaviors.dojo.AutoCompleteBehavior.java

License:Apache License

@Override
public void renderHead(final Component _component, final IHeaderResponse _response) {
    super.renderHead(_component, _response);
    // add wicket ajax to be sure that is is included
    CoreLibrariesContributor.contributeAjax(this.component.getApplication(), _response);

    final CharSequence ajaxBaseUrl = Strings
            .escapeMarkup(this.component.getRequestCycle().getUrlRenderer().getBaseUrl().toString());
    _response.render(JavaScriptHeaderItem.forScript("Wicket.Ajax.baseUrl=\"" + ajaxBaseUrl + "\";",
            "wicket-ajax-base-url"));

    _response.render(AbstractEFapsHeaderItem.forCss(AutoCompleteBehavior.CSS));

    final String comboBoxId = "cb" + _component.getMarkupId();
    final StringBuilder js = new StringBuilder().append("var ").append(comboBoxId);

    switch (this.settings.getAutoType()) {
    case SUGGESTION:
        js.append(" = new AutoSuggestion({");
        break;//from  w w  w  .jav a2  s.  c  o m
    case TOKEN:
        js.append(" = new AutoTokenInput({");
        break;
    default:
        js.append(" = new AutoComplete({");
        break;
    }

    js.append("id:\"").append(_component.getMarkupId()).append("\",").append("name:\"")
            .append(this.settings.getFieldName()).append("\",").append("placeHolder:ph,").append("store: as,")
            .append("value: \"\",").append("callbackUrl:\"" + getCallbackUrl() + "\",");

    switch (this.settings.getAutoType()) {
    case TOKEN:
        break;
    default:
        final String id = ((AutoCompleteField) _component).getItemValue();
        final String label = ((AutoCompleteField) _component).getItemLabel();
        // only if both value are valid it makes sence to add it
        if (StringUtils.isNotEmpty(id) && StringUtils.isNotEmpty(label)) {
            js.append("item: { id:\"").append(id).append("\", name:\"").append(label).append("\", label:\"")
                    .append(label).append("\"},");
        }
        break;
    }

    if (this.settings.getFieldConfiguration().hasProperty(UIFormFieldProperty.WIDTH)
            && !this.settings.getFieldConfiguration().isTableField()) {
        js.append("style:\"width:").append(this.settings.getFieldConfiguration().getWidth()).append("\",");
    }
    if (!this.settings.isHasDownArrow()) {
        js.append("hasDownArrow:").append(this.settings.isHasDownArrow()).append(",");
    }
    if (this.settings.getMinInputLength() > 1) {
        js.append("minInputLength:").append(this.settings.getMinInputLength()).append(",");
    }
    if (this.settings.getSearchDelay() != 500) {
        js.append("searchDelay:").append(this.settings.getSearchDelay()).append(",");
    }

    if (!"p".equals(this.settings.getParamName())) {
        js.append("paramName:\"").append(this.settings.getParamName()).append("\",");
    }

    if (!this.settings.getExtraParameters().isEmpty()) {
        js.append("extraParameters:[");
        boolean first = true;
        for (final String ep : this.settings.getExtraParameters()) {
            if (first) {
                first = false;
            } else {
                js.append(",");
            }
            js.append("\"").append(ep).append("\"");
        }
        js.append("],");
    }
    if (Type.SUGGESTION.equals(this.settings.getAutoType())) {
        js.append("labelAttr: \"label\",");
    }

    js.append("searchAttr: \"name\"}, \"").append(_component.getMarkupId()).append("\");\n");

    if (this.settings.isRequired() && !Type.TOKEN.equals(this.settings.getAutoType())) {
        js.append("on(").append(comboBoxId).append(", 'change', function() {").append("var label=")
                .append(comboBoxId).append(".item.label;")
                .append("if (!(label === undefined || label === null)) {").append(comboBoxId)
                .append(".item.name=label;").append(comboBoxId).append(".set(\"item\",").append(comboBoxId)
                .append(".item);").append("}");
        if (this.fieldUpdate != null) {
            js.append(this.fieldUpdate.getCallbackScript4Dojo());
        }
        js.append("});\n");
    } else if (this.fieldUpdate != null) {
        js.append("on(").append(comboBoxId).append(", 'change', function() {")
                .append(this.fieldUpdate.getCallbackScript4Dojo()).append("});\n");
    }

    if (!_component.getBehaviors(SetSelectedRowBehavior.class).isEmpty()) {
        js.append("on(").append(comboBoxId).append(", 'focus', function() {").append(
                _component.getBehaviors(SetSelectedRowBehavior.class).get(0).getJavaScript("this.valueNode"))
                .append("});\n");
    }
    if (Type.TOKEN.equals(this.settings.getAutoType())) {
        final List<IOption> tokens = ((AutoCompleteField) _component).getTokens();
        for (final IOption token : tokens) {
            js.append(comboBoxId).append(".addToken(\"")
                    .append(StringEscapeUtils.escapeEcmaScript(token.getValue().toString())).append("\",\"")
                    .append(StringEscapeUtils.escapeEcmaScript(token.getLabel())).append("\");\n");
        }
    }
    _response.render(AutoCompleteHeaderItem.forScript(js.toString(), EnumSet.of(this.settings.getAutoType())));
}