Java tutorial
/* * Copyright (c) 2007 NTT DATA Corporation * * 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 jp.terasoluna.fw.web.struts.actions; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jp.terasoluna.fw.service.thin.BLogicResult; import jp.terasoluna.fw.web.struts.action.ActionMappingEx; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * <p> * {NX?A_E??[h???s??BLogicN?sNX?B<br> * Action?BLogicN?s?BEJB?B * </p> * <p> * BLogicNX?s?A * Bean`t@CBLogicActionBean`?A * businessLogicv?peBI?WbNNX * L?A<property>vfw?B * struts-config.xml??B * </p> * <p> * <strong>Bean`t@C?</strong> * <code><pre> * <bean name="/download/downloadAction" scope="prototype" * <strong>class="jp.terasoluna.fw.web.struts.actions.DownloadBLogicAction"</strong>> * <strong><property name="businessLogic"> * <ref bean="downloadBLogic"></ref> * </property></strong> * </bean> * <bean id="downloadBLogic" scope="prototype" * <strong>class="jp.terasoluna.sample1.download.blogic.DownloadBLogic"</strong>> * </bean> * </pre></code> * </p> * <p> * <strong>struts-config.xmlBLogicAction?</strong> * <code><pre> * <action path="/download/downloadAction" * name="_downloadForm" * validate="true" * scope="session" * input="/download/download.jsp"/> * </pre></code> * </p> * * @param <P> rWlX?WbNlJavaBeanw */ public class DownloadBLogicAction<P> extends BLogicAction<P> { /** * ?ONX?B */ Log log = LogFactory.getLog(DownloadBLogicAction.class); /** * BLogicResultWebwIuWFNgf?s?B * <p> * NX<code>resultObject</code>???A * _E??[h???s?B * <ul> * <li>{@link AbstractDownloadObject}p?NX??</li> * <li>{@link AbstractDownloadObject}p?NXv?peBP???</li> * </ul> * * @param result BLogicResultCX^X * @param request HTTPNGXg * @param response HTTPX|X * @param mappingEx gANV}bsO */ @Override protected void processBLogicResult(BLogicResult result, HttpServletRequest request, HttpServletResponse response, ActionMappingEx mappingEx) { super.processBLogicResult(result, request, response, mappingEx); if (result.getResultString() != null) { if (log.isWarnEnabled()) { log.warn("result string must not be set. path :" + request.getPathInfo()); } result.setResultString(null); } FileDownloadUtil.download(result.getResultObject(), request, response); } }