Package de.odysseus.calyxo.struts.forms

Source Code of de.odysseus.calyxo.struts.forms.CalyxoActionForm

/*
* 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.struts.forms;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import de.odysseus.calyxo.forms.FormData;
import de.odysseus.calyxo.forms.misc.FormDataMap;
import de.odysseus.calyxo.forms.misc.RequestInputValues;

/**
* Generic Calyxo action form class for use with the Calyxo Forms tags.
* Valid form data is kept in a map.
* <p/>
* The input values to be validated are directly taken from the request.
* Struts users should not derive from this class to add form bean
* properties they are do with ordinary action forms: the populated bean
* properties will neither be used as inputs to the validation, nor
* will the Calyxo input tags get their values out of these properties.
* <p/>
* Again: this implementation does not use bean properties or mapped
* properties and does not work with the form input tags shipped with struts!
* If you want to use "legacy" action forms with the struts tags, take
* one of the action form base classes from the
* <code>de.odysseus.calyxo.struts.forms.legacy</code> package.
*
* @author Christoph Beck
*/
public class CalyxoActionForm extends ActionForm implements FormData {
  private final FormsDelegate validator = new FormsDelegate();
  private final FormData data;

  /**
   * Default constructor.
   * Causes the form data to be kept in a map.
   */
  public CalyxoActionForm() {
    this(new FormDataMap(new HashMap()));
  }

  /**
   * Constructor.
   * Subclasses may pass their own form data implementation.
   */
  protected CalyxoActionForm(FormData data) {
    super();
   
    this.data = data;
  }

  /* (non-Javadoc)
   * @see de.odysseus.calyxo.forms.FormData#_getProperty(java.lang.String)
   */
  public Object _getProperty(String name) throws Exception {
    return data._getProperty(name);
  }

  /* (non-Javadoc)
   * @see de.odysseus.calyxo.forms.FormData#_setProperty(java.lang.String, java.lang.Object)
   */
  public void _setProperty(String name, Object value) throws Exception {
    data._setProperty(name, value);
  }

  /* (non-Javadoc)
   * @see de.odysseus.calyxo.forms.FormData#_getWrapped()
   */
  public Object _getWrapped() {
    return data._getWrapped();
  }

  /**
   * Validate form; input values are taken from the request.
   * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
   */
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
      return validator.validate(mapping, request, new RequestInputValues(request));
  }
}
TOP

Related Classes of de.odysseus.calyxo.struts.forms.CalyxoActionForm

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.