Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: formatting, switching versions order
Wiki Markup
{composition-setup}
cloak.memory.duration = 3
{composition-setup}

Adding a markup filter

In some very rare cases it might be necessary to add an additional markup filter to the default list. Lets say you want to log a warning or throw an exception in case of an empty src attribute like <img src="">. The Image component is not able to handle it because the wicket id is missing. A markup filter in contrast iterates over all xml tags and is able to detect the problem and to throw an exception.

Note: a markup filter is not able to detect an AttributeModifier changing the src attribute to an empty string.

Wicket 1.

...

2:

Code Block
public class MyApplication extends Application
{
    protected void init()
    {
        IMarkupFilter filter = new HtmlProblemFinder(HtmlProblemFinder.ERR_THROW_EXCEPTION);
        getMarkupSettings().setMarkupParserFactory(new MarkupParserFactory(this, filter));
    }
}

Wicket 1.1

Code Block

public class MyApplication extends Application
{
    {panel}
    public MarkupParser newMarkupParser()
    {
        final MarkupParser parser = new MarkupParser(container, 
            new XmlPullParser(settings.getDefaultMarkupEncoding())
            {
                public void initFilterChain()
                {
                    appendMarkupFilter(new HtmlProblemFinder(HtmlProblemFinder.ERR_THROW_EXCEPTION));
                }
            }
        );
        parser.configure(getSettings());
        return parser;
    }
{panel}
}

Wicket 1.2:

Code Block

public class MyApplication extends Application
{
{panel}
    protected void init()
    {
        IMarkupFilter filter = new HtmlProblemFinder(HtmlProblemFinder.ERR_THROW_EXCEPTION);
        getMarkupSettings().setMarkupParserFactory(new MarkupParserFactory(this, filter));
    }
{panel}
}