/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.cocoon.webapps.session.acting; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.acting.FormValidatorAction; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Session; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.webapps.session.SessionConstants; import java.util.Map; /** * This is the action used to validate Request parameters. * The validation rules are either embedded within the form * * <pre> * <session:form name="info_form"> * <session:action>next_page</session:action> * <session:content> * <session:inputxml name="name" type="text" context="trackdemo" path="/user/name"/> * </session:content> * <session:validate> * <root> * <parameter name="name" type="string" nullable="no"/> * <constraint-set name="form_a_set"> * <validate name="name"/> * </constraint-set> * </root> * </session:validate> * </session:form> * </pre> * * or described via the external xml file referenced * through the "src" attribute * (the format is defined in AbstractValidatorAction). * Then the constraint-set to be used has to be identified * through the "constraint-set" element * * <pre> * <session:form name="info_form> * <session:action>next_page</session:action> * <session:content> * <session:inputxml name="name" type="text" context="trackdemo" path="/user/name"/> * </session:content> * <session:validate src="descriptor.xml"> * <constraint-set name="form_a_set"/> * </session:validate> * </session:form> * </pre> * * Since the validation rules are contained within the form document * they are read and supplied by the SessionTransformer. * So this action has to be used in conjunction with the SessionTransformer. * The "next_page" pipeline might look like this: * * <pre> * <map:match pattern="next_page"> * <map:act type="session-form"> * <map:generate src="next_page.xml"/> * <map:transform type="session"/> * <map:transform src="simple2html.xsl"/> * <map:serialize/> * </map:act> * <map:generate src="first_page.xml"/> * <map:transform type="session"/> * <map:transform src="simple2html.xsl"/> * <map:serialize/> * </map:match> * </pre> * * where "session-form" is configured as SessionFormAction * * @see org.apache.cocoon.acting.FormValidatorAction * @see org.apache.cocoon.acting.AbstractValidatorAction * * @author <a href="mailto:gcasper@s-und-n.de">Guido Casper</a> * @author <a href="mailto:haul@apache.org">Christian Haul</a> * @deprecated This block is deprecated and will be removed in future versions. * @version $Id$ */ public class SessionFormAction extends FormValidatorAction { /* (non-Javadoc) * @see org.apache.cocoon.acting.AbstractValidatorAction#getDescriptor(org.apache.cocoon.environment.SourceResolver, org.apache.avalon.framework.parameters.Parameters) */ protected Configuration getDescriptor( SourceResolver resolver, Map objectModel, Parameters parameters) { Session session = ObjectModelHelper.getRequest(objectModel).getSession(true); return (Configuration) session.getAttribute( ObjectModelHelper.getRequest(objectModel).getParameter( SessionConstants.SESSION_FORM_PARAMETER)); } }