Return-Path: Delivered-To: apmail-click-commits-archive@www.apache.org Received: (qmail 73987 invoked from network); 19 Jul 2010 08:40:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Jul 2010 08:40:05 -0000 Received: (qmail 24881 invoked by uid 500); 19 Jul 2010 08:40:05 -0000 Delivered-To: apmail-click-commits-archive@click.apache.org Received: (qmail 24864 invoked by uid 500); 19 Jul 2010 08:40:04 -0000 Mailing-List: contact commits-help@click.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: click-dev@click.apache.org Delivered-To: mailing list commits@click.apache.org Received: (qmail 24856 invoked by uid 99); 19 Jul 2010 08:40:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Jul 2010 08:40:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Jul 2010 08:40:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3168A23889EA; Mon, 19 Jul 2010 08:38:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r965385 - /click/trunk/click/framework/src/org/apache/click/ClickServlet.java Date: Mon, 19 Jul 2010 08:38:37 -0000 To: commits@click.apache.org From: sabob@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100719083837.3168A23889EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sabob Date: Mon Jul 19 08:38:36 2010 New Revision: 965385 URL: http://svn.apache.org/viewvc?rev=965385&view=rev Log: moved ajax target control lookup into separate method Modified: click/trunk/click/framework/src/org/apache/click/ClickServlet.java Modified: click/trunk/click/framework/src/org/apache/click/ClickServlet.java URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ClickServlet.java?rev=965385&r1=965384&r2=965385&view=diff ============================================================================== --- click/trunk/click/framework/src/org/apache/click/ClickServlet.java (original) +++ click/trunk/click/framework/src/org/apache/click/ClickServlet.java Mon Jul 19 08:38:36 2010 @@ -1869,10 +1869,11 @@ public class ClickServlet extends HttpSe } /** - * Process all ajax controls and return true if the page should continue + * Process all Ajax controls and return true if the page should continue * processing, false otherwise. * * @param context the request context + * @param eventDispatcher the event dispatcher * @param controlRegistry the control registry * @return true if the page should continue processing, false otherwise */ @@ -1881,43 +1882,10 @@ public class ClickServlet extends HttpSe boolean continueProcessing = true; - Control ajaxTarget = null; - - if (logger.isTraceEnabled()) { - logger.trace(" the following controls have been registered as potential Ajax targets:"); - if (controlRegistry.hasAjaxTargetControls()) { - for (Control control : controlRegistry.getAjaxTargetControls()) { - HtmlStringBuffer buffer = new HtmlStringBuffer(); - String controlClassName = ClassUtils.getShortClassName(control.getClass()); - buffer.append(" ").append(controlClassName); - buffer.append(": name='").append(control.getName()).append("'"); - logger.trace(buffer.toString()); - } - } else { - logger.trace(" *no* control has been registered"); - } - } - - for (Control control : controlRegistry.getAjaxTargetControls()) { - - if (control.isAjaxTarget(context)) { - ajaxTarget = control; - // The first matching control will be processed. Multiple matching - // controls are not supported - break; - } - } + // Find the ajax target control for the Ajax request + Control ajaxTarget = getAjaxTarget(context, controlRegistry); if (ajaxTarget != null) { - if (logger.isTraceEnabled()) { - HtmlStringBuffer buffer = new HtmlStringBuffer(); - buffer.append(" invoked: '"); - buffer.append(ajaxTarget.getName()).append("' "); - String className = ClassUtils.getShortClassName(ajaxTarget.getClass()); - buffer.append(className); - buffer.append(".isAjaxTarget() : true (target Ajax control found)"); - logger.trace(buffer.toString()); - } // Process the control if (!ajaxTarget.onProcess()) { @@ -1939,12 +1907,6 @@ public class ClickServlet extends HttpSe logger.trace(" *no* behavior was registered while processing the control"); } } - } else { - - if (logger.isTraceEnabled()) { - String msg = " *no* target control was found for Ajax request"; - logger.trace(msg); - } } return continueProcessing; @@ -2198,6 +2160,61 @@ public class ClickServlet extends HttpSe // Private methods -------------------------------------------------------- /** + * Find and return the Ajax target control or null if no Ajax target was found. + * + * @param context the request context + * @param controlRegistry the control registry + * @return the target Ajax target control or null if no Ajax target was found + */ + private Control getAjaxTarget(Context context, ControlRegistry controlRegistry) { + + Control ajaxTarget = null; + + if (logger.isTraceEnabled()) { + logger.trace(" the following controls have been registered as potential Ajax targets:"); + if (controlRegistry.hasAjaxTargetControls()) { + for (Control control : controlRegistry.getAjaxTargetControls()) { + HtmlStringBuffer buffer = new HtmlStringBuffer(); + String controlClassName = ClassUtils.getShortClassName(control.getClass()); + buffer.append(" ").append(controlClassName); + buffer.append(": name='").append(control.getName()).append("'"); + logger.trace(buffer.toString()); + } + } else { + logger.trace(" *no* control has been registered"); + } + } + + for (Control control : controlRegistry.getAjaxTargetControls()) { + + if (control.isAjaxTarget(context)) { + ajaxTarget = control; + // The first matching control will be processed. Multiple matching + // controls are not supported + break; + } + } + + if (logger.isTraceEnabled()) { + if (ajaxTarget == null) { + String msg = " *no* target control was found for Ajax request"; + logger.trace(msg); + + } else { + HtmlStringBuffer buffer = new HtmlStringBuffer(); + buffer.append(" invoked: '"); + buffer.append(ajaxTarget.getName()).append("' "); + String className = ClassUtils.getShortClassName(ajaxTarget.getClass()); + buffer.append(className); + buffer.append(".isAjaxTarget() : true (target Ajax control found)"); + logger.trace(buffer.toString()); + } + } + + return ajaxTarget; + } + + /** * Log the request parameter names and values. * * @param request the HTTP servlet request