wicket-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Colman (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WICKET-4829) ComponentResolvers created in app init ignore non standard namespace
Date Tue, 23 Oct 2012 01:56:11 GMT

    [ https://issues.apache.org/jira/browse/WICKET-4829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13482035#comment-13482035
] 

Chris Colman commented on WICKET-4829:
--------------------------------------

I have implemented a fix that works for my tests.
GitHub won't let me publish my changes so I include the diffs here in the hope that one of
the wicket devs may add these patches soon.

diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java
b/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java
index 27779c5..ed4802b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java
@@ -23,6 +23,7 @@ import org.apache.wicket.markup.HtmlSpecialTag;
 import org.apache.wicket.markup.Markup;
 import org.apache.wicket.markup.MarkupElement;
 import org.apache.wicket.markup.MarkupParser;
+import org.apache.wicket.markup.MarkupStream;
 import org.apache.wicket.markup.MarkupResourceStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -176,4 +177,21 @@ public abstract class AbstractMarkupFilter implements IMarkupFilter
 		}
 		return wicketNamespace;
 	}
+
+	/**
+	 * @return the namespace of the given markup or loaded markup
+	 */
+	protected String getWicketNamespace(MarkupStream markupStream)
+	{
+		String wicketNamespace;
+		if (markupStream != null)
+		{
+			wicketNamespace = markupStream.getWicketNamespace();
+		}
+		else
+		{
+			wicketNamespace = getWicketNamespace();
+		}
+		return wicketNamespace;
+	}
 }
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
index f812f76..84a959e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
@@ -178,7 +178,7 @@ public final class InlineEnclosureHandler extends AbstractMarkupFilter
 		if (Strings.isEmpty(inlineEnclosureChildId) == false)
 		{
 			String id = tag.getId();
-			if (id.startsWith(getWicketNamespace()))
+			if (id.startsWith(getWicketNamespace(markupStream)))
 			{
 				id = id + container.getPage().getAutoIndex();
 			}
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java
b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java
index 420a881..4f1c593 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java
@@ -141,7 +141,7 @@ public final class RelativePathPrefixHandler extends AbstractMarkupFilter
 			{
 				if (tag.getId() == null)
 				{
-					tag.setId(getWicketRelativePathPrefix());
+					tag.setId(getWicketRelativePathPrefix(null));
 					tag.setAutoComponentTag(true);
 				}
 				tag.addBehavior(RELATIVE_PATH_BEHAVIOR);
@@ -157,7 +157,7 @@ public final class RelativePathPrefixHandler extends AbstractMarkupFilter
 	public Component resolve(final MarkupContainer container, final MarkupStream markupStream,
 		final ComponentTag tag)
 	{
-		if ((tag != null) && (tag.getId().equals(getWicketRelativePathPrefix())))
+		if ((tag != null) && (tag.getId().equals(getWicketRelativePathPrefix(markupStream))))
 		{
 			String id = tag.getId() + container.getPage().getAutoIndex();
 
@@ -169,8 +169,8 @@ public final class RelativePathPrefixHandler extends AbstractMarkupFilter
 		return null;
 	}
 
-	private String getWicketRelativePathPrefix()
+	private String getWicketRelativePathPrefix(MarkupStream markupStream)
 	{
-		return getWicketNamespace() + WICKET_RELATIVE_PATH_PREFIX_CONTAINER_ID;
+		return getWicketNamespace(markupStream) + WICKET_RELATIVE_PATH_PREFIX_CONTAINER_ID;
 	}
 }
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
index 65aa1d1..204b21e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
@@ -91,7 +91,7 @@ public final class WicketMessageTagHandler extends AbstractMarkupFilter
 				// if this is a raw tag we need to set the id to something so
 				// that wicket will not merge this as raw markup and instead
 				// pass it on to a resolver
-				tag.setId(getWicketMessageIdPrefix());
+				tag.setId(getWicketMessageIdPrefix(null));
 				tag.setAutoComponentTag(true);
 				tag.setModified(true);
 			}
@@ -163,11 +163,11 @@ public final class WicketMessageTagHandler extends AbstractMarkupFilter
 	public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag
tag)
 	{
 		// localize any raw markup that has wicket:message attrs
-		if ((tag != null) && (tag.getId().startsWith(getWicketMessageIdPrefix())))
+		if ((tag != null) && (tag.getId().startsWith(getWicketMessageIdPrefix(markupStream))))
 		{
 			Component wc;
 			int autoIndex = container.getPage().getAutoIndex();
-			String id = getWicketMessageIdPrefix() + autoIndex;
+			String id = getWicketMessageIdPrefix(markupStream) + autoIndex;
 
 			if (tag.isOpenClose())
 			{
@@ -189,8 +189,8 @@ public final class WicketMessageTagHandler extends AbstractMarkupFilter
 		return wicketNamespace + ':' + "message";
 	}
 
-	private String getWicketMessageIdPrefix()
+	private String getWicketMessageIdPrefix(MarkupStream markupStream)
 	{
-		return getWicketNamespace() + WICKET_MESSAGE_CONTAINER_ID;
+		return getWicketNamespace(markupStream) + WICKET_MESSAGE_CONTAINER_ID;
 	}
 }

                
> ComponentResolvers created in app init ignore non standard namespace
> --------------------------------------------------------------------
>
>                 Key: WICKET-4829
>                 URL: https://issues.apache.org/jira/browse/WICKET-4829
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 6.2.0
>         Environment: Windows, Java 6.x
>            Reporter: Chris Colman
>         Attachments: nonStdNamespaceBugW6.2.zip
>
>
> Initially this problem was occurring in a page with an enclosure and so I thought it
was specific to enclosures but on minimalizing the quickstart it is apparent that it happens
on any page where a non default namespace is specified AND a href has a relative path.
>  
> The attached quickstart has a single page with no components at all. In 6.x the page
fails if a non default namespace is specified in the <html> tag. This works fine in
1.4.x and 1.5.x
> <html xmls:foobar>
> causes:
> Last cause: Unable to find component with id 'foobar_relative_path_prefix_' in [HtmlHeaderContainer
[Component id = _header_0]]
> 	Expected: '_header_0.foobar_relative_path_prefix_'.
> 	Found with similar names: ''
> If we remove the non standard namespace declaration from the html element then the page
works fine.
> Also, if we remove the line:
> <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet"/>
> from the HomePage.html then the problem doesn't occur.
> Problem could possibly be related to how RelativePathPrefixHanlder deals with a non default
namespace.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message