001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license 003 * agreements. See the NOTICE file distributed with this work for additional information regarding 004 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 005 * "License"); you may not use this file except in compliance with the License. You may obtain a 006 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 007 * law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 008 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 009 * for the specific language governing permissions and limitations under the License. 010 */ 011 012 package javax.portlet.faces; 013 014 import java.util.Map; 015 016 import javax.faces.context.FacesContext; 017 018 import javax.portlet.faces.Bridge; 019 020 public class BridgeUtil 021 { 022 public static boolean isPortletRequest() 023 { 024 Map<String, Object> m = FacesContext.getCurrentInstance().getExternalContext().getRequestMap(); 025 Bridge.PortletPhase phase = (Bridge.PortletPhase) m.get(Bridge.PORTLET_LIFECYCLE_PHASE); 026 if (phase != null) 027 { 028 return true; 029 } 030 else 031 { 032 return false; 033 } 034 } 035 036 public static Bridge.PortletPhase getPortletRequestPhase() 037 { 038 Map<String, Object> m = FacesContext.getCurrentInstance().getExternalContext().getRequestMap(); 039 return (Bridge.PortletPhase) m.get(Bridge.PORTLET_LIFECYCLE_PHASE); 040 } 041 042 }