FormsAction.java :  » Web-Framework » calyxo » de » odysseus » calyxo » forms » control » Java Open Source

Java Open Source » Web Framework » calyxo 
calyxo » de » odysseus » calyxo » forms » control » FormsAction.java
/*
 * Copyright 2004, 2005, 2006 Odysseus Software GmbH
 *
 * 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 de.odysseus.calyxo.forms.control;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import de.odysseus.calyxo.control.conf.DispatchConfig;
import de.odysseus.calyxo.control.misc.AbstractAction;
import de.odysseus.calyxo.forms.FormProperties;


/**
 * Convenience base action class to be used with forms plugin.
 * This class' {@link #execute(HttpServletRequest, HttpServletResponse)} method
 * grabs out the action's form properties which have just been validated and passes
 * it to {@link #execute(HttpServletRequest, HttpServletResponse, FormProperties)}.
 *
 * @author Christoph Beck
 */
public abstract class FormsAction extends AbstractAction {
  private FormsSupport formsSupport;

  /**
   * Get the module's forms support instance.
   */
  protected final FormsSupport getFormsSupport() {
    return formsSupport;
  }
  
  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.AbstractAction#init()
   */
  protected void init() throws Exception {
    super.init();
    formsSupport = (FormsSupport)FormsSupport.getInstance(getModuleContext());
  }
  
  
  /* (non-Javadoc)
   * @see de.odysseus.calyxo.control.Command#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  public final DispatchConfig execute(
    HttpServletRequest request,
    HttpServletResponse response) throws Exception {
    // dig for our validated form properties
    FormProperties properties = formsSupport.getFormProperties(request, getActionConfig().getPath());
    return execute(request, response, properties);
  }

  /**
   * Process request; to be implemented by subclasses.
   * This method additionally gets in the form properties validated for this
   * action's form.
   * @param request the http request we're in
   * @param response the http response
   * @param formProperties the form properties just validated
   * @return dispatch configuration
   * @throws Exception
   */
  public abstract DispatchConfig execute(
    HttpServletRequest request,
    HttpServletResponse response,
    FormProperties formProperties) throws Exception;
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.