Author: ivaynberg
Date: Thu Dec 14 09:33:52 2006
New Revision: 487273

URL: http://svn.apache.org/viewvc?view=rev&rev=487273
Log:
throw exception if trying to add a component to ajax request target that has 
setoutputmarkupid set to false

Modified:
    
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/ajax/AjaxRequestTarget.java

Modified: 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/ajax/AjaxRequestTarget.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/ajax/AjaxRequestTarget.java?view=diff&rev=487273&r1=487272&r2=487273
==============================================================================
--- 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/ajax/AjaxRequestTarget.java
 (original)
+++ 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/ajax/AjaxRequestTarget.java
 Thu Dec 14 09:33:52 2006
@@ -196,6 +196,13 @@
         */
        public final void addComponent(Component component)
        {
+               if (component==null) {
+                       throw new IllegalArgumentException("component cannot be 
null");
+               }
+               if (component.getOutputMarkupId()==false)
+               {
+                       throw new IllegalArgumentException("cannot update 
component that does not have setOutputMarkupId property set to true. Component: 
"+component.toString());
+               }
                addComponent(component, component.getMarkupId());
        }
 
@@ -261,11 +268,11 @@
         */
        public void detach(final RequestCycle requestCycle)
        {
-//             Page page = requestCycle.getRequest().getPage();
-//             if(page != null) 
-//             {
-//                     page.detachModels();
-//             }
+               // Page page = requestCycle.getRequest().getPage();
+               // if(page != null)
+               // {
+               // page.detachModels();
+               // }
        }
 
        /**
@@ -360,7 +367,7 @@
                                final Map.Entry entry = (Entry)it.next();
                                final Component component = 
(Component)entry.getValue();
                                final String markupId = (String)entry.getKey();
-                               
+
                                respondComponent(response, markupId, component);
                        }
 
@@ -475,9 +482,9 @@
 
                page.startComponentRender(component);
                component.renderComponent();
-               
-               respondHeaderContribution(response, component);         
-               
+
+               respondHeaderContribution(response, component);
+
                page.endComponentRender(component);
 
                page.setVersioned(versioned);
@@ -501,9 +508,9 @@
                encodingBodyResponse.reset();
        }
 
-       
+
        private HtmlHeaderContainer header = null;
-       
+
        /**
         * 
         * @param response
@@ -511,11 +518,11 @@
         */
        private void respondHeaderContribution(final Response response, final 
Component component)
        {
-               if (header == null) {
-                       header = new HtmlHeaderContainer(
-                                       HtmlHeaderSectionHandler.HEADER_ID);    
+               if (header == null)
+               {
+                       header = new 
HtmlHeaderContainer(HtmlHeaderSectionHandler.HEADER_ID);
                }
-               
+
                if (component.getPage().get(HtmlHeaderSectionHandler.HEADER_ID) 
!= null)
                {
                        component.getPage().replace(header);
@@ -548,7 +555,7 @@
                                        }
                                }
                        });
-               }                               
+               }
 
                RequestCycle.get().setResponse(oldResponse);
 


Reply via email to