Author: jdonnerstag Date: Sat Jun 18 08:58:18 2011 New Revision: 1137144 URL: http://svn.apache.org/viewvc?rev=1137144&view=rev Log: fixed: xmlns:wicket="http://wicket.apache.org" rendered for each panel see also WICKET-2874 Issue: WICKET-3812
Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/TagUtils.java wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/SimplePanel_4.java Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/TagUtils.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/TagUtils.java?rev=1137144&r1=1137143&r2=1137144&view=diff ============================================================================== --- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/TagUtils.java (original) +++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/TagUtils.java Sat Jun 18 08:58:18 2011 @@ -16,6 +16,9 @@ */ package org.apache.wicket.markup; +import org.apache.wicket.Component; +import org.apache.wicket.MarkupContainer; + /** * Some utils to handle tags which otherwise would bloat the Tag AP. @@ -141,4 +144,38 @@ public class TagUtils } return false; } + + /** + * Copy attributes from e.g. <wicket:panel> (or border) to the "calling" tag. + * + * @see <a href="http://issues.apache.org/jira/browse/WICKET-2874">WICKET-2874</a> + * @see <a href="https://issues.apache.org/jira/browse/WICKET-3812">WICKET-3812</a> + * + * @param component + * @param tag + */ + public static void copyAttributes(final Component component, final ComponentTag tag) + { + IMarkupFragment markup = ((MarkupContainer)component).getMarkup(null); + String namespace = markup.getMarkupResourceStream().getWicketNamespace() + ":"; + + MarkupElement elem = markup.get(0); + if (elem instanceof ComponentTag) + { + ComponentTag panelTag = (ComponentTag)elem; + for (String key : panelTag.getAttributes().keySet()) + { + // exclude "wicket:XX" attributes + if (key.startsWith(namespace) == false) + { + tag.append(key, panelTag.getAttribute(key), ", "); + } + } + } + else + { + throw new MarkupException(markup.getMarkupResourceStream(), + "Expected a Tag but found raw markup: " + elem.toString()); + } + } } \ No newline at end of file Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java?rev=1137144&r1=1137143&r2=1137144&view=diff ============================================================================== --- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java (original) +++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java Sat Jun 18 08:58:18 2011 @@ -48,47 +48,13 @@ public abstract class AssociatedMarkupSo { } - /** - * {@inheritDoc} - */ @Override public void onComponentTag(final Component component, final ComponentTag tag) { super.onComponentTag(component, tag); - // Can be explicitly called - copyAttributes(component, tag); - } - - /** - * Copy attributes from <wicket:XXX> to the "calling" tag - * - * @param component - * @param tag - */ - public void copyAttributes(final Component component, final ComponentTag tag) - { - IMarkupFragment markup = ((MarkupContainer)component).getMarkup(null); - String namespace = markup.getMarkupResourceStream().getWicketNamespace() + ":"; - - MarkupElement elem = markup.get(0); - if (elem instanceof ComponentTag) - { - ComponentTag panelTag = (ComponentTag)elem; - for (String key : panelTag.getAttributes().keySet()) - { - // exclude "wicket:XX" attributes - if (key.startsWith(namespace) == false) - { - tag.append(key, panelTag.getAttribute(key), ", "); - } - } - } - else - { - throw new MarkupException(markup.getMarkupResourceStream(), - "Expected a Tag but found raw markup: " + elem.toString()); - } + // In case you want to copy attributes from <wicket:panel> tag to the "calling" tag, you + // may subclass onComponentTag of your component and call TagUtils.copyAttributes(). } /** Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/SimplePanel_4.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/SimplePanel_4.java?rev=1137144&r1=1137143&r2=1137144&view=diff ============================================================================== --- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/SimplePanel_4.java (original) +++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/SimplePanel_4.java Sat Jun 18 08:58:18 2011 @@ -16,6 +16,9 @@ */ package org.apache.wicket.markup.html.panel; +import org.apache.wicket.markup.ComponentTag; +import org.apache.wicket.markup.TagUtils; + /** * Mock page for testing. @@ -35,4 +38,13 @@ public class SimplePanel_4 extends Panel { super(id); } + + @Override + protected void onComponentTag(ComponentTag tag) + { + super.onComponentTag(tag); + + // WICKET-2874, WICKET-3812 + TagUtils.copyAttributes(this, tag); + } }