org.apache.tapestry5.upload.components.Upload Maven / Gradle / Ivy
// Copyright 2007-2013 The Apache Software Foundation
//
// 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 org.apache.tapestry5.upload.components;
import org.apache.tapestry5.*;
import org.apache.tapestry5.annotations.Events;
import org.apache.tapestry5.annotations.Mixin;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Path;
import org.apache.tapestry5.corelib.base.AbstractField;
import org.apache.tapestry5.corelib.mixins.RenderDisabled;
import org.apache.tapestry5.http.services.Request;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.FieldValidatorDefaultSource;
import org.apache.tapestry5.services.FormSupport;
import org.apache.tapestry5.upload.services.MultipartDecoder;
import org.apache.tapestry5.upload.services.UploadedFile;
import java.util.Locale;
/**
* A component to upload a file.
*/
@SuppressWarnings({"UnusedDeclaration"})
@Events(EventConstants.VALIDATE)
public class Upload extends AbstractField
{
public static final String MULTIPART_ENCTYPE = "multipart/form-data";
/**
* The uploaded file. Note: This is only guaranteed to be valid while processing the form submission. Subsequently
* the content may have been cleaned up.
*/
@Parameter(required = true, principal = true, autoconnect = true)
private UploadedFile value;
/**
* The object that will perform input validation. The "validate:" binding prefix is generally used to provide this
* object in a declarative fashion.
*/
@Parameter(defaultPrefix = BindingConstants.VALIDATE)
@SuppressWarnings("unchecked")
private FieldValidator