Package org.jasig.portal.utils.web.flow

Source Code of org.jasig.portal.utils.web.flow.RuntimeMvcViewFactory

/**
* Licensed to Jasig under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Jasig 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.jasig.portal.utils.web.flow;

import javax.portlet.PortletRequest;

import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.web.servlet.View;
import org.springframework.webflow.context.ExternalContext;
import org.springframework.webflow.engine.builder.BinderConfiguration;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.mvc.portlet.PortletMvcView;
import org.springframework.webflow.mvc.servlet.ServletMvcView;
import org.springframework.webflow.mvc.view.AbstractMvcView;
import org.springframework.webflow.mvc.view.AbstractMvcViewFactory;
import org.springframework.webflow.mvc.view.FlowViewResolver;

/**
* Implementation that does reflection on the native request to determine if a {@link PortletMvcView} or a
* {@link ServletMvcView} should be used.
*
* @author Eric Dalquist
* @version $Revision$
*/
public class RuntimeMvcViewFactory extends AbstractMvcViewFactory {
   
    public RuntimeMvcViewFactory(Expression viewId, FlowViewResolver viewResolver, ExpressionParser expressionParser,
            ConversionService conversionService, BinderConfiguration binderConfiguration,
            MessageCodesResolver messageCodesResolver) {
        super(viewId, viewResolver, expressionParser, conversionService, binderConfiguration, messageCodesResolver);
    }

    /* (non-Javadoc)
     * @see org.springframework.webflow.mvc.view.AbstractMvcViewFactory#createMvcView(org.springframework.web.servlet.View, org.springframework.webflow.execution.RequestContext)
     */
    @Override
    protected AbstractMvcView createMvcView(View view, RequestContext context) {
        final ExternalContext externalContext = context.getExternalContext();
        final Object nativeRequest = externalContext.getNativeRequest();
        if (nativeRequest instanceof PortletRequest) {
            return new PortletMvcView(view, context);
        }
       
        return new ServletMvcView(view, context);
    }

}
TOP

Related Classes of org.jasig.portal.utils.web.flow.RuntimeMvcViewFactory

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.