8000 Sandbox/hierarchy completion by jdonnerstag · Pull Request #1 · ivaynberg/wicket · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Sandbox/hierarchy completion #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: sandbox/hierarchy-completion
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 78 additions & 54 deletions wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
10000
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ else if (getParent() instanceof AbstractRepeater)
}

// the current markup tag
tag = (ComponentTag)markup.get();


tag = markup.getTag();
if (tag.isClose())
{
if (stack.isEmpty())
Expand All @@ -258,15 +256,19 @@ else if (getParent() instanceof AbstractRepeater)
Component child = parent.get(tag.getId());
if (child == null)
{
// try to deque a child component if one has not been found
child = findComponentByMarkup(tag);
}

if (child == null)
{
// try to deque a child component if one has not been found

for (int j = stack.size() - 1; j >= 0; j--)
{
// we try to find a queued component from the deepest nested parent all the way
// to the owner of the markup
ComponentAndTag cat = stack.get(j);
ArrayList<Component> queue = cat.component.getMetaData(QUEUE);
List<Component> queue = cat.component.getMetaData(QUEUE);
if (queue == null)
{
continue;
Expand All @@ -280,6 +282,7 @@ else if (getParent() instanceof AbstractRepeater)
break;
}
}

if (child != null)
{
queue.remove(child);
Expand All @@ -291,12 +294,12 @@ else if (getParent() instanceof AbstractRepeater)
if (child == null)
{
// if we didnt find a queued child we could use try the resolvers

child = ComponentResolvers.resolve(parent, markup, tag, null);
if (child != null)
{
tag.setId(child.getId());
tag.setModified(true);
child.setMarkup(markup.getMarkupFragment());
// child.setAuto(true);
// tag.setModified(true);
}
}

Expand All @@ -308,12 +311,12 @@ else if (getParent() instanceof AbstractRepeater)
// that will leave components in the queue and ondetach() will bomb
}

if (child != null && child.isAuto())
{
// TODO this is yet another hack, need to figure out how auto components fit into
// this and why they dont get correctly resolved second time around
child.setAuto(false);
}
// if (child != null && child.isAuto())
// {
// // TODO this is yet another hack, need to figure out how auto components fit into
// // this and why they dont get correctly resolved second time around
// child.setAuto(false);
// }

if (child == null)
{
Expand Down Expand Up @@ -363,6 +366,22 @@ else if (child instanceof MarkupContainer)
}
}

private Component findComponentByMarkup(final ComponentTag tag)
{
for (Component comp : this)
{
IMarkupFragment markup2 = comp.getMarkup();

// By purpose compare the object ids
if ((markup2 != null) && (markup2.get(0) == tag))
{
return comp;
}
}

return null;
}

private void lateAdd(MarkupContainer parent, Component queued)
{
parent.add(queued);
Expand Down Expand Up @@ -530,36 +549,36 @@ public MarkupContainer addOrReplace(final Component... childs)
* stream to be used to render the component.
* @return True, if component has been added
*/
public final boolean autoAdd(final Component component, MarkupStream markupStream)
{
if (component == null)
{
throw new IllegalArgumentException("argument component may not be null");
}

// Replace strategy
component.setAuto(true);

if (markupStream != null)
{
component.setMarkup(markupStream.getMarkupFragment());
}

// Add the child to the parent.

// Arguably child.setParent() can be used as well. It connects the child to the parent and
// that's all what most auto-components need. Unfortunately child.onDetach() will not / can
// not be invoked, since the parent doesn't known its one of his children. Hence we need to
// properly add it.
int index = children_indexOf(component);
if (index >= 0)
{
children_remove(index);
}
add(component);

return true;
}
// public final boolean autoAdd(final Component component, MarkupStream markupStream)
// {
// if (component == null)
// {
// throw new IllegalArgumentException("argument component may not be null");
// }
//
// // Replace strategy
// component.setAuto(true);
//
// if (markupStream != null)
// {
// component.setMarkup(markupStream.getMarkupFragment());
// }
//
// // Add the child to the parent.
//
// // Arguably child.setParent() can be used as well. It connects the child to the parent and
// // that's all what most auto-components need. Unfortunately child.onDetach() will not / can
// // not be invoked, since the parent doesn't known its one of his children. Hence we need to
// // properly add it.
// int index = children_indexOf(component);
// if (index >= 0)
// {
// children_remove(index);
// }
// add(component);
//
// return true;
// }

/**
* @param component
Expand Down Expand Up @@ -1687,16 +1706,21 @@ protected final boolean renderNext(final MarkupStream markupStream)
Component component = get(id);
if (component == null)
{
component = ComponentResolvers.resolve(this, markupStream, tag, null);
if ((component != null) && (component.getParent() == null))
{
autoAdd(component, markupStream);
}
else if (component != null)
{
component.setMarkup(markupStream.getMarkupFragment());
}
}
component = findComponentByMarkup(tag);
}
// if (component == null)
// {
// component = ComponentResolvers.resolve(this, markupStream, tag, null);
// if ((component != null) && (component.getParent() == null))
// {
// throw new WicketRuntimeException("Still need autoAdd(): " + tag.toString());
// // autoAdd(component, markupStream);
// }
// else if (component != null)
// {
// component.setMarkup(markupStream.getMarkupFragment());
// }
// }

// Failed to find it?
if (component != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,14 @@ public IMarkupFragment getMarkup()
"Bug: The Wicket internal instance of HtmlHeaderContainer is not connected to a parent");
}

IMarkupFragment markup = super.getMarkup();
if (markup != null)
{
return markup;
}

// Get the page markup
IMarkupFragment markup = getPage().getMarkup();
markup = getPage().getMarkup();
if (markup == null)
{
throw new MarkupException("Unable to get page markup: " + getPage().toString());
Expand Down
0