Domanda

I'm trying to use Fragments within an Extend component but it throws an MarkupNotFoundException.

The code is similar to this:

BasePanel.html

<?xml version="1.0" encoding="UTF-8" ?>
<wicket:panel xmlns:wicket="http://wicket.apache.org">

    <div wicket:id="dialog">
        <div class="titlebar">
            <h3 wicket:id="dialogTitle">[[ dialog title ]]</h3>
            <div wicket:id="dialogCloseBtn" class="closeBtn right"></div>
        </div>
        <wicket:child />
    </div>

</wicket:panel>

ChildPanel.html

<?xml version="1.0" encoding="UTF-8" ?>

<wicket:extend xmlns:wicket="http://wicket.apache.org">

    <wicket:panel wicket:id="panel1" />

    <wicket:fragment wicket:id="fragment1">
    </wicket:fragment>

</wicket:extend>

ChildPanel.java

public class ChildPanel extends Panel  
{
    public ChildPanel(String id, IModel<?> model) 
    {
         super(id, model);
         add(new Fragment("panel1", "fragment1", this); 
    }
}

The problem resides in Wicket Markup.java class:

public final IMarkupFragment find(final String id)
{
    Args.notEmpty(id, "id");

    MarkupStream stream = new MarkupStream(this);
    stream.setCurrentIndex(0);
    while (stream.hasMore())
    {
        MarkupElement elem = stream.get();
        if (elem instanceof ComponentTag)
        {
            ComponentTag tag = stream.getTag();
            if (tag.isOpen() || tag.isOpenClose())
            {
                if (tag.getId().equals(id))
                {
                    return stream.getMarkupFragment();
                }
                if (tag.isOpen() && !tag.hasNoCloseTag() && !(tag instanceof WicketTag) &&
                    !"head".equals(tag.getName()) && !tag.isAutoComponentTag())
                {
                    stream.skipToMatchingCloseTag(tag);
                }
            }
        }

        stream.next();
    }

    return null;
}

When the application iterates over the stream it looks in the BasePanel markup. After looking open tag <div wicket:id="dialog"> it iterates to the closing tag </div>, so it didn't look inside the ChildPanel markup.

Do you have any suggestion or solution?

Thanks, Manuel

È stato utile?

Soluzione

There is an opened jira issue related with this topic. You could follow instructions to solve it here: https://issues.apache.org/jira/browse/WICKET-4545.

Altri suggerimenti

You can declare a <wicket:fragment> inside <wicket:extend>, but not a <wicket:panel> (panel1). Try using <wicket:container> instead.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top