Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 Philip Helger (www.helger.com) philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package com.helger.webbasics.ajax.executor;
 
 
 
Provides a common implementation of the com.helger.webbasics.ajax.IAjaxExecutor interface for as easy reuse as possible.

Author(s):
Philip Helger
 
 public abstract class AbstractAjaxExecutor implements IAjaxExecutor
 {
  
The name of the request parameter used by jQuery to indicate "no cache". Use this constant for parameter filtering.
 
   public static final String REQUEST_PARAM_JQUERY_NO_CACHE = "_";
 
   public AbstractAjaxExecutor ()
   {}
 
   public void initExecution (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
   {
     // By default do nothing
   }
 
   public void registerExternalResources ()
   {
     // empty default implementation
   }
 
   protected void modifyRequestParamMap (@Nonnull final MapBasedAttributeContainer aParams)
   {
     // Remove the jQuery timestamp parameter
   }

  
This method must be overridden by every handler

Parameters:
aRequestScope The current request scope. Never null.
Returns:
the result object. May not be null
Throws:
java.lang.Exception
 
   @Nonnull
   protected abstract IAjaxResponse mainHandleRequest (@Nonnull IRequestWebScopeWithoutResponse aRequestScopethrows Exception;
 
   @Nonnull
   @SuppressFBWarnings ("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
   public final IAjaxResponse handleRequest (@Nonnull final IRequestWebScopeWithoutResponse aRequestScopethrows Exception
   {
     // Main invocation
     final IAjaxResponse aResult = mainHandleRequest (aRequestScope);
     if (aResult == null)
       throw new IllegalStateException ("Invocation of " +
                                        CGStringHelper.getClassLocalName (getClass ()) +
                                        " returned null response!");
 
     // Return invocation result
     return aResult;
   }
 
   @Override
   public String toString ()
   {
     return new ToStringGenerator (this).toString ();
  }
New to GrepCode? Check out our FAQ X