View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.controller;
17  
18  import javax.servlet.http.HttpServletRequest;
19  
20  import org.apache.struts.action.ActionErrors;
21  import org.apache.struts.action.ActionMapping;
22  import org.apache.struts.action.ActionMessage;
23  import org.apache.struts.upload.MultipartRequestHandler;
24  import org.apache.struts.validator.DynaValidatorForm;
25  import org.seasar.tuigwaa.model.common.EntityUtils;
26  import org.seasar.tuigwaa.util.TgwContext;
27  import org.seasar.tuigwaa.util.TgwResource;
28  import org.seasar.tuigwaa.util.TgwUtils;
29  
30  public class DynaConverterValidationForm extends DynaValidatorForm {
31  
32  	private static final long serialVersionUID = 1L;
33  
34  	public ActionErrors validate(ActionMapping mapping,
35  			HttpServletRequest request) {
36  
37  		Boolean maxLengthExceeded = (Boolean) request
38  				.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
39  		if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {
40  			String errorpage = TgwResource.getProperty("option.fileexceed.errorpage");
41  			TgwContext.bindPageName(errorpage);
42  			ActionErrors errors = new ActionErrors();
43  			ActionMessage message = new ActionMessage(
44  					"error.message.maxlengthexceed");
45  			errors.add("file", message);
46  			return errors;
47  		}
48  
49  		// convert
50  		String siteName = TgwContext.getSiteName();
51  		String formName = mapping.getName();
52  		TgwUtils.convert(siteName, formName, this);
53  
54  		// bind page
55  		String pageName = (String) EntityUtils.getProperty(this, "_pageName_");
56  		TgwContext.bindPageName(pageName);
57  
58  		return super.validate(mapping, request);
59  	}
60  }