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

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

Introduction

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

Prototype

public MarkupException(final String message) 

Source Link

Document

Constructor

Usage

From source file:com.olegchir.flussonic_userlinks.wicket.IncludeResolver.IncludeResolver.java

License:Apache License

/**
 * Handles resolving the wicket:include tag. If a filename is specified this
 * file will be looked up. If a key is specified it's value is looked up
 * using the resource mechanism. The looked up value will then be used as
 * filename./*ww  w .  j  a  v a 2s .com*/
 *
 */
public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) {

    if ((tag instanceof WicketTag) && tagname.equalsIgnoreCase(tag.getName())) {
        WicketTag wtag = (WicketTag) tag;

        String fileName = StringUtils.trimToNull(wtag.getAttribute("file"));
        String fileKey = StringUtils.trimToNull(wtag.getAttribute("key"));

        if (null != fileKey) {
            if (null != fileName) {
                throw new MarkupException("Wrong format of: you must not use file and key attribtue at once");
            }
            fileName = StringUtils.trimToNull(container.getString(fileKey));
            if (null == fileName) {
                throw new MarkupException("The key inside could not be resolved");
            }

        } else if (null == fileName) {
            throw new MarkupException("Wrong format of: specify the file or key attribute");
        }

        final String id = "_" + tagname + "_" + container.getPage().getAutoIndex();
        IncludeContainer ic = new IncludeContainer(id, fileName, fileKey, markupStream);
        ic.setRenderBodyOnly(container.getApplication().getMarkupSettings().getStripWicketTags());
        //            container.autoAdd(ic, markupStream);

        return ic;

    }
    return null;
}

From source file:org.artifactory.common.wicket.component.links.BaseTitledLink.java

License:Open Source License

protected final void replaceBody(MarkupStream markupStream, ComponentTag openTag, String html) {
    replaceComponentTagBody(markupStream, openTag, html);

    if (!wasOpenCloseTag) {
        markupStream.skipRawMarkup();/*from  w w w .j a v  a2 s  . co m*/
        if (!markupStream.get().closes(openTag)) {
            throw new MarkupException(
                    "close tag not found for tag: " + openTag.toString() + ". Component: " + toString());
        }
    }
}

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

License:Apache License

/**
 * Method is overwritten to prevent the annoing warnings from Component to come up.
 * The warning come up due to the reason that this component moves the tags from parent
 * element to its child./*from ww w  . j a v a  2s . c  o m*/
 */
@Override
protected void onRender() {
    final IMarkupFragment markup = getMarkup();
    if (markup == null) {
        throw new MarkupException("Markup not found. Component: " + toString());
    }

    final MarkupStream markupStream = new MarkupStream(markup);

    // Get mutable copy of next tag
    final ComponentTag openTag = markupStream.getTag();
    final ComponentTag tag = openTag.mutable();

    // Call any tag handler
    onComponentTag(tag);

    // If we're an openclose tag
    if (!tag.isOpenClose() && !tag.isOpen()) {
        // We were something other than <tag> or <tag/>
        markupStream.throwMarkupException("Method renderComponent called on bad markup element: " + tag);
    }

    if (tag.isOpenClose() && openTag.isOpen()) {
        markupStream.throwMarkupException("You can not modify a open tag to open-close: " + tag);
    }

    markupStream.next();

    getMarkupSourcingStrategy().onComponentTagBody(this, markupStream, tag);
}

From source file:org.odlabs.wiquery.plugins.ckeditor.CKeditorBehavior.java

License:Open Source License

/**
 * {@inheritDoc}/* w  w  w .  j a v a  2s.  c  om*/
 * @see org.apache.wicket.behavior.AbstractBehavior#onComponentTag(org.apache.wicket.Component, org.apache.wicket.markup.ComponentTag)
 */
@Override
public void onComponentTag(Component component, ComponentTag tag) {
    if (!tag.getName().equalsIgnoreCase("textarea")) {
        throw new MarkupException("The jQuery CKeditor behavior needs a textarea");
    }
}

From source file:org.wicketstuff.jeeweb.JEEWebResolver.java

License:Apache License

@Override
public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) {
    if (tag instanceof WicketTag) {
        WicketTag wtag = (WicketTag) tag;
        if ("jsp".equalsIgnoreCase(wtag.getName())) {
            String file = wtag.getAttributes().getString("file");
            if (file == null || file.trim().length() == 0) {
                throw new MarkupException(
                        "Wrong format of <wicket:jsp file='/foo.jsp'>: attribute 'file' is missing");
            }/*from   w  w  w.  j a va2  s  .  com*/
            return new ServletAndJspFileContainer(file, Type.JSP);
        } else if ("jsf".equalsIgnoreCase(wtag.getName())) {
            String file = wtag.getAttributes().getString("file");
            if (file == null || file.trim().length() == 0) {
                throw new MarkupException(
                        "Wrong format of <wicket:jsf file='/foo.xhtml'>: attribute 'file' is missing");
            }
            return new ServletAndJspFileContainer(file, Type.JSF);
        } else if ("servlet".equalsIgnoreCase(wtag.getName())) {
            String path = wtag.getAttributes().getString("path");
            if (path == null || path.trim().length() == 0) {
                throw new MarkupException(
                        "Wrong format of <wicket:servlet path='/Test'>: attribute 'path' is missing");
            }
            return new ServletAndJspFileContainer(path, Type.SERVLET);
        }
    }
    return null;
}

From source file:sf.wicklet.wicketext.markup.impl.ReadOnlyRootMarkup.java

License:Apache License

private IMarkupFragment createFragment(final ComponentTag c, final int start, final int end) {
    final ReadOnlyRootMarkup ret = new ReadOnlyRootMarkup();
    int level = c.isOpenClose() ? 0 : 1;
    ret.add(c);//from   w  w w .j  a  va 2  s .  c  o m
    for (int k = start; level > 0 && k < end; ++k) {
        final IMarkupElement e = elements.get(k);
        ret.add(e);
        if (e instanceof ComponentTag) {
            final ComponentTag cc = (ComponentTag) e;
            if (cc.isOpen()) {
                ++level;
            } else if (cc.isClose()) {
                --level;
            } else if (!cc.isOpenClose()) {
                assert (false);
            }
        }
    }
    if (level != 0) {
        throw new MarkupException("Fragment is not well formed: " + ret);
    }
    return ret;
}

From source file:sf.wicklet.wicketext.markup.impl.WicketWriter.java

License:Apache License

public IRootMarkup build() {
    raw(xhtml);//w w  w . j a  va2  s  .  c  o  m
    final ReadOnlyRootMarkup ret = new ReadOnlyRootMarkup(markups);
    if (!tagStack.isEmpty()) {
        throw new MarkupException("Markup is not well formed: " + ret);
    }
    if (xhtml.level() != 0) {
        throw new MarkupException("XHtmlFragment builder is not well-formed: " + xhtml.toString());
    }
    return ret;
}