WICKET-5315 PriorityHeaderItem+OnDomReadyHeaderItem has no priority in Ajax 
response


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/bfd46496
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/bfd46496
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/bfd46496

Branch: refs/heads/5299-ajax-strategy
Commit: bfd4649656f4f51c8d1a164cc14cb5b8dc71f89d
Parents: 841e9a4
Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
Authored: Mon Aug 12 16:51:17 2013 +0300
Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
Committed: Mon Aug 12 16:51:17 2013 +0300

----------------------------------------------------------------------
 .../wicket/ajax/AbstractAjaxResponse.java       | 21 +++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/bfd46496/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
index 668e3af..0f656b0 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
@@ -28,9 +28,11 @@ import org.apache.wicket.Component;
 import org.apache.wicket.Page;
 import org.apache.wicket.markup.head.HeaderItem;
 import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.IWrappedHeaderItem;
 import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
 import org.apache.wicket.markup.head.OnEventHeaderItem;
 import org.apache.wicket.markup.head.OnLoadHeaderItem;
+import org.apache.wicket.markup.head.PriorityHeaderItem;
 import org.apache.wicket.markup.head.internal.HeaderResponse;
 import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
 import org.apache.wicket.markup.parser.filter.HtmlHeaderSectionHandler;
@@ -527,6 +529,16 @@ public abstract class AbstractAjaxResponse
                @Override
                public void render(HeaderItem item)
                {
+                       PriorityHeaderItem priorityHeaderItem = null;
+                       while (item instanceof IWrappedHeaderItem)
+                       {
+                               if (item instanceof PriorityHeaderItem)
+                               {
+                                       priorityHeaderItem = 
(PriorityHeaderItem) item;
+                               }
+                               item = ((IWrappedHeaderItem) item).getWrapped();
+                       }
+
                        if (item instanceof OnLoadHeaderItem)
                        {
                                if (!wasItemRendered(item))
@@ -547,7 +559,14 @@ public abstract class AbstractAjaxResponse
                        {
                                if (!wasItemRendered(item))
                                {
-                                       
AbstractAjaxResponse.this.domReadyJavaScripts.add(((OnDomReadyHeaderItem)item).getJavaScript());
+                                       if (priorityHeaderItem != null)
+                                       {
+                                               
AbstractAjaxResponse.this.domReadyJavaScripts.add(0, 
((OnDomReadyHeaderItem)item).getJavaScript());
+                                       }
+                                       else
+                                       {
+                                               
AbstractAjaxResponse.this.domReadyJavaScripts.add(((OnDomReadyHeaderItem)item).getJavaScript());
+                                       }
                                        markItemRendered(item);
                                }
                        }

Reply via email to