Author: knopp
Date: Wed Aug 27 06:01:01 2008
New Revision: 689469

URL: http://svn.apache.org/viewvc?rev=689469&view=rev
Log:
javadoc

Modified:
    
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java
    
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxUrlCodingStrategy.java

Modified: 
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java?rev=689469&r1=689468&r2=689469&view=diff
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java
 (original)
+++ 
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java
 Wed Aug 27 06:01:01 2008
@@ -45,6 +45,35 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * A request target that produces ajax response envelopes used on the client 
side to update
+ * component markup as well as evaluate arbitrary javascript.
+ * <p>
+ * A component whose markup needs to be updated should be added to this target 
via
+ * AjaxRequestTarget#addComponent(Component) method. Its body will be rendered 
and added to the
+ * envelope when the target is processed, and refreshed on the client side 
when the ajax response is
+ * received.
+ * <p>
+ * It is important that the component whose markup needs to be updated 
contains an id attribute in
+ * the generated markup that is equal to the value retrieved from 
Component#getMarkupId(). This can
+ * be accomplished by either setting the id attribute in the html template, or 
using an attribute
+ * modifier that will add the attribute with value Component#getMarkupId() to 
the tag ( such as
+ * MarkupIdSetter )
+ * <p>
+ * Any javascript that needs to be evaluated on the client side can be added 
using
+ * AjaxRequestTarget#append/prependJavascript(String). For example, this 
feature can be useful when
+ * it is desirable to link component update with some javascript effects.
+ * <p>
+ * The target provides a listener interface [EMAIL PROTECTED] IListener} that 
can be used to add code that
+ * responds to various target events by adding listeners via
+ * [EMAIL PROTECTED] #addListener(IListener)} 
+ * 
+ * @since 1.2
+ * 
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Eelco Hillenius
+ * @author Matej Knopp
+ */
 public class AjaxRequestTarget implements IRequestTarget
 {
 
@@ -58,7 +87,6 @@
        /**
         * An [EMAIL PROTECTED] AjaxRequestTarget} listener that can be used to 
respond to various target-related
         * events
-        * 
         */
        public static interface IListener
        {
@@ -396,6 +424,15 @@
                }
        }
 
+       /**
+        * Adds a component entry to the list of components to be rendered
+        * 
+        * @param entry
+        *            component entry to be rendered
+        * 
+        * @return <code>true</code> if the component was added, 
<code>false</code> if the
+        *          component or some of it's parents is already in the list
+        */
        public boolean addComponent(ComponentEntry entry)
        {
                if (entry == null)
@@ -428,6 +465,16 @@
                return true;
        }
 
+       /**
+        * Adds a component to the list of components to be rendered
+        * 
+        * @param component
+        *            component to be rendered
+        * 
+        * @return <code>true</code> if the component was added, 
<code>false</code> if the
+        *          component or some of it's parents is already in the list
+        */
+
        public boolean addComponent(Component component)
        {
                if (component == null)
@@ -864,8 +911,13 @@
                return stringResponse.toString();
        }
 
+       /**
+        * 
+        * @param redirect
+        */
        public void setRedirect(String redirect)
        {
+               // TODO: Implement redirect
                this.redirect = redirect;
        }
 
@@ -894,17 +946,17 @@
                                component.prepareForRender();
                        }
                        catch (RuntimeException e)
-               {
-                   try
-                   {
-                       component.afterRender();
-                   }
-                   catch (RuntimeException e2)
-                   {
-                       // ignore this one could be a result off.
-                   }
-                   throw e;
-               }
+                       {
+                               try
+                               {
+                                       component.afterRender();
+                               }
+                               catch (RuntimeException e2)
+                               {
+                                       // ignore this one could be a result 
off.
+                               }
+                               throw e;
+                       }
                }
        }
 
@@ -967,13 +1019,13 @@
                {
                        JSONArray components = new JSONArray();
                        response.put("components", components);
-                       
+
                        if (!entries.isEmpty())
                        {
                                prepareRender();
 
                                response.put("header", 
respondHeaderContribution());
-                               
+
                                for (ComponentEntry entry : entries)
                                {
                                        
components.put(renderComponentEntry(entry));
@@ -1003,10 +1055,10 @@
                                appendJavascripts.put(renderJavascriptEntry(e));
                        }
                }
-               
-               WebResponse webResponse = (WebResponse) 
requestCycle.getResponse();
+
+               WebResponse webResponse = 
(WebResponse)requestCycle.getResponse();
                prepareResponse(webResponse);
-               
+
                webResponse.write("if (false) (");
                webResponse.write(response.toString());
                webResponse.write(")");
@@ -1015,7 +1067,7 @@
        private void prepareResponse(WebResponse response)
        {
                final Application app = Application.get();
-               
+
                // Determine encoding
                final String encoding = 
app.getRequestCycleSettings().getResponseRequestEncoding();
 
@@ -1027,7 +1079,10 @@
                response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
                response.setHeader("Cache-Control", "no-cache, 
must-revalidate");
                response.setHeader("Pragma", "no-cache");
-       }       
+       }
 
+       /**
+        * Dummy AJAX request target instance used by [EMAIL PROTECTED] 
AjaxBehavior} to generate AJAX URL prefix.
+        */
        public static final AjaxRequestTarget DUMMY = new AjaxRequestTarget();
 }

Modified: 
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxUrlCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxUrlCodingStrategy.java?rev=689469&r1=689468&r2=689469&view=diff
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxUrlCodingStrategy.java
 (original)
+++ 
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxUrlCodingStrategy.java
 Wed Aug 27 06:01:01 2008
@@ -33,6 +33,11 @@
 {
        private final String mountPath;
 
+       /**
+        * Construct.
+        * 
+        * @param mountPath
+        */
        public AjaxUrlCodingStrategy(String mountPath)
        {
                this.mountPath = mountPath;
@@ -50,23 +55,23 @@
                        return null;
                }
        }
-       
+
        private Page getPage(RequestParameters parameters)
        {
                String page = getParameter(parameters, PARAM_PAGE_ID);
                String elements[] = page.split(":");
                int pageId;
-               String pageMapName = null; 
+               String pageMapName = null;
                int version = 0;
                if (elements.length == 2)
                {
-                       pageId = Integer.valueOf(elements[0]);  
+                       pageId = Integer.valueOf(elements[0]);
                        version = Integer.valueOf(elements[1]);
                }
                else if (elements.length == 3)
                {
                        pageMapName = elements[0];
-                       pageId = Integer.valueOf(elements[1]);  
+                       pageId = Integer.valueOf(elements[1]);
                        version = Integer.valueOf(elements[2]);
                }
                else
@@ -116,13 +121,13 @@
                        throw new IllegalStateException("Couldn't find 
component with id '" +
                                getParameter(requestParameters, 
PARAM_COMPONENT_ID) + "'.");
                }
-               
+
                int behaviorIndex = 
Integer.valueOf(getParameter(requestParameters, PARAM_BEHAVIOR_INDEX));
-               
+
                int urlDepth = Integer.valueOf(getParameter(requestParameters, 
PARAM_URL_DEPTH));
-               
+
                
RequestCycle.get().getRequest().getRequestParameters().setUrlDepth(urlDepth);
-               
+
                return new AjaxRequestTarget(component, behaviorIndex);
        }
 
@@ -138,12 +143,26 @@
        }
 
        private static final String PARAM_PREFIX = "wicketNG:";
+       
+       /** Timestamp query parameter */
        public static final String PARAM_TIMESTAMP = PARAM_PREFIX + "timestamp";
+       
+       /** ComponentId query parameter */
        public static final String PARAM_COMPONENT_ID = PARAM_PREFIX + 
"componentId";
+       
+       /** PageId query parameter */
        public static final String PARAM_PAGE_ID = PARAM_PREFIX + "pageId";
+       
+       /** FormId query parameter */
        public static final String PARAM_FORM_ID = PARAM_PREFIX + "formId";
+       
+       /** Listener interface query parameter */
        public static final String PARAM_LISTENER_INTEFACE = PARAM_PREFIX + 
"listenerInterface";
+       
+       /** Behavior index query parameter */
        public static final String PARAM_BEHAVIOR_INDEX = PARAM_PREFIX + 
"behaviorIndex";
+       
+       /** URL Depth query parameter */
        public static final String PARAM_URL_DEPTH = PARAM_PREFIX + "urlDepth";
 
        public boolean matches(IRequestTarget requestTarget)


Reply via email to