當前位置: 首頁>>代碼示例>>Java>>正文


Java ExternalContext類代碼示例

本文整理匯總了Java中javax.faces.context.ExternalContext的典型用法代碼示例。如果您正苦於以下問題:Java ExternalContext類的具體用法?Java ExternalContext怎麽用?Java ExternalContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ExternalContext類屬於javax.faces.context包,在下文中一共展示了ExternalContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: redirectToServiceDetails

import javax.faces.context.ExternalContext; //導入依賴的package包/類
public String redirectToServiceDetails() {
    logger.logDebug("entering redirectToServiceDetails");
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext extContext = context.getExternalContext();
    String viewId = Marketplace.MARKETPLACE_ROOT + "/serviceDetails.jsf";

    try {
        viewId = extContext.getRequestContextPath()
                + viewId
                + ui.getSelectedServiceKeyQueryPart(String.valueOf(model
                        .getSelectedServiceKey()))
                + ui.getMarketplaceIdQueryPart();
        String urlLink = context.getExternalContext().encodeActionURL(
                viewId);
        JSFUtils.redirect(extContext, urlLink);
    } catch (IOException e) {
        extContext.log(
                getClass().getName() + ".redirectToServiceDetails()", e);
    } finally {
        // reset requested key;
        model.setSelectedServiceKey(null);
    }
    return null;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:25,代碼來源:ServiceDetailsCtrl.java

示例2: encodeAllAsElement

import javax.faces.context.ExternalContext; //導入依賴的package包/類
@Override
protected void encodeAllAsElement(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
   // call super...
  super.encodeAllAsElement(context, rc, component, bean);

  // now evaluate the EL
  // We need to evaluate it here and store it on the sessionMap because
  // during UploadedFileProcessor.processFile() there is no FacesContext
  RequestContext requestContext = RequestContext.getCurrentInstance();
  Object maxMemory = requestContext.getUploadedFileMaxMemory();
  Object maxDiskSpace = requestContext.getUploadedFileMaxDiskSpace();
  Object tempDir = requestContext.getUploadedFileTempDir();
  ExternalContext external = context.getExternalContext();
  Map<String, Object> sessionMap = external.getSessionMap();
  sessionMap.put(UploadedFileProcessor.MAX_MEMORY_PARAM_NAME, maxMemory);
  sessionMap.put(UploadedFileProcessor.MAX_DISK_SPACE_PARAM_NAME, maxDiskSpace);
  sessionMap.put(UploadedFileProcessor.TEMP_DIR_PARAM_NAME, tempDir);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:25,代碼來源:SimpleInputFileRenderer.java

示例3: _parseDisplayNameParam

import javax.faces.context.ExternalContext; //導入依賴的package包/類
private static <E extends Enum> Collection<E> _parseDisplayNameParam(
  ExternalContext external,
  String          paramName,
  Class<E>        enumClass, 
  E               defaultValue
  ) throws InvalidConfigException
{
  try
  {
    return Enums.parseDisplayNameEnumRequestParameter(external,
                                                      paramName,
                                                      enumClass,
                                                      defaultValue);
  }
  catch (EnumParseException e)
  {
    throw new InvalidConfigException(e.getMessage());
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:20,代碼來源:PregenConfig.java

示例4: ParamPregenConfig

import javax.faces.context.ExternalContext; //導入依賴的package包/類
public ParamPregenConfig(FacesContext context)
  throws InvalidConfigException
{
  ExternalContext external = context.getExternalContext();

  _containerTypes = _parseDisplayNameParam(external,
                                           "containerType",
                                           ContainerType.class,
                                           ContainerType.SERVLET);

  _requestTypes = _parseDisplayNameParam(external,
                                         "requestType",
                                         RequestType.class,
                                         RequestType.NONSECURE);
  
  _styleClassTypes = _parseDisplayNameParam(external,
                                            "styleClassType",
                                            StyleClassType.class,
                                            StyleClassType.COMPRESSED);
  
  _targetDirectoryPath = _getTargetDirectoryPath(context);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:PregenConfig.java

示例5: _getServletContextFromFacesContext

import javax.faces.context.ExternalContext; //導入依賴的package包/類
/**
 *Returns the servlet context object from the FacesContext
 * 
 * @param context
 * @return
 */
private Object _getServletContextFromFacesContext(FacesContext context)
{
  ExternalContext ec = null;
  Object sc = null;
  
  if (context != null)
  {
    ec = context.getExternalContext();
    
    if (ec != null)
    {
      sc = ec.getContext();
    }
  }
  
  return sc;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:24,代碼來源:ResourceServlet.java

示例6: getSkin

import javax.faces.context.ExternalContext; //導入依賴的package包/類
/**
 * given the skinId, pass back the Skin.
 *
 * @param context FacesContext. If not available, pass in null.
 * @param skinId
 * @return Skin that is in this SkinFactory and has the skinId.
 * @deprecated use SkinProvider to query skins
 */
@Deprecated
@Override
public Skin getSkin(FacesContext context, String skinId)
{
  context = SkinUtils.getNonNullFacesContext(context);

  if (skinId == null)
  {
    _LOG.warning("CANNOT_GET_SKIN_WITH_NULL_SKINID");
    return null;
  }

  ExternalContext ec = context.getExternalContext();
  SkinMetadata skinMetadata = new SkinMetadata.Builder().id(skinId).build();
  return SkinProvider.getCurrentInstance(ec).getSkin(ec, skinMetadata);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:25,代碼來源:SkinFactoryImpl.java

示例7: getSelectedServiceKeyQueryPart

import javax.faces.context.ExternalContext; //導入依賴的package包/類
public String getSelectedServiceKeyQueryPart(String selectedServiceKey) {
    String selectedService = "";
    ExternalContext extContext = getFacesContext().getExternalContext();
    String charEncoding = extContext.getRequestCharacterEncoding();

    try {
        String name = URLEncoder.encode("selectedServiceKey", charEncoding);
        String value = URLEncoder.encode(selectedServiceKey, charEncoding);
        selectedService = '?' + name + '=' + value;
    } catch (UnsupportedEncodingException e) {
        extContext.log(getClass().getName()
                + ".getSelectedServiceQueryPart()", e);

    }
    return selectedService;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:17,代碼來源:UiDelegate.java

示例8: setup

import javax.faces.context.ExternalContext; //導入依賴的package包/類
@Before
public void setup() {
    validator = new CaptchaValidator();
    sessionMock = new HttpSessionStub(Locale.ENGLISH);
    context = new FacesContextStub(Locale.ENGLISH) {
        @Override
        public ExternalContext getExternalContext() {
            ExternalContext exContext = spy(new ExternalContextStub(
                    Locale.ENGLISH));
            doReturn(sessionMock).when(exContext).getSession(false);
            return exContext;
        }
    };

    inputField = new HtmlInputText() {
        @Override
        public String getClientId(FacesContext ctx) {
            return "";
        }
    };
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:22,代碼來源:CaptchaValidatorTest.java

示例9: saveState

import javax.faces.context.ExternalContext; //導入依賴的package包/類
/**
 * Saves the current state to the session.  Running this is only manditory if you need to preserve a request across
 * the natural request boundry in a portlet environment.  Executing this function outside of a portlet environment will
 * not alter operation of his class.
 * 
 * @param ec the ExternalContext to save the stateMap to.
 */
public void saveState(ExternalContext ec)
{
  RequestType type = ExternalContextUtils.getRequestType(ec);
  if(type.isPortlet() && !type.isResponseWritable())
  {
    try
    {
      //TODO: use reflection here but it can be replaced..
      Object actionResp = ec.getResponse();
      Method m = actionResp.getClass().getMethod("setRenderParameter", String.class, String.class);
      String uuid = UUID.randomUUID().toString();

      ec.getSessionMap().put(_STATE_MAP+"."+uuid, this);
      m.invoke(actionResp, _STATE_MAP, uuid);
    }
    catch(Throwable t)
    {
      //TODO: Log exception
      t.printStackTrace();
    }
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:30,代碼來源:RequestStateMap.java

示例10: registerFacesDependencies

import javax.faces.context.ExternalContext; //導入依賴的package包/類
public static void registerFacesDependencies(ConfigurableListableBeanFactory beanFactory) {
	beanFactory.registerResolvableDependency(FacesContext.class, new ObjectFactory<FacesContext>() {
		@Override
		public FacesContext getObject() {
			return FacesContext.getCurrentInstance();
		}
		@Override
		public String toString() {
			return "Current JSF FacesContext";
		}
	});
	beanFactory.registerResolvableDependency(ExternalContext.class, new ObjectFactory<ExternalContext>() {
		@Override
		public ExternalContext getObject() {
			return FacesContext.getCurrentInstance().getExternalContext();
		}
		@Override
		public String toString() {
			return "Current JSF ExternalContext";
		}
	});
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:WebApplicationContextUtils.java

示例11: setUp

import javax.faces.context.ExternalContext; //導入依賴的package包/類
@Override
protected void setUp() throws IOException
{
  MFacesContext ctx = new MFacesContext(MApplication.sharedInstance(), true);
  ExternalContext externalContext = ctx.getExternalContext();

  Map<String, Object> applicationMap = externalContext.getApplicationMap();
  applicationMap.put(TrinidadSkinProvider.TRINDIAD_SKIN_PROVIDER_KEY,
                     new TrinidadSkinProvider());
  applicationMap.put(ExternalSkinProvider.EXTERNAL_SKIN_PROVIDER_KEY,
                     new ExternalSkinProvider());
  applicationMap.put(SkinProvider.SKIN_PROVIDER_INSTANCE_KEY,
                     new SkinProviderRegistry());
  _facesContext = ctx;
  _externalContext = externalContext;
  _provider = SkinProvider.getCurrentInstance(_externalContext);

  if (SkinFactory.getFactory() == null)
    SkinFactory.setFactory(new SkinFactoryImpl());
  RenderKitBootstrap.setFactories(_facesConfigInfo);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,代碼來源:SkinProviderTest.java

示例12: reloadSkins

import javax.faces.context.ExternalContext; //導入依賴的package包/類
/**
 * @inheritDoc
 */
@Override
@Deprecated
public void reloadSkins(ExternalContext externalContext, SkinFactory skinFactory)
{
  // ask all subordinate configurators to reload their skins
  // We do not load the base skins and trinidad-skins eagerly.
  // When any configurator tries to register its skins to the SKinFactory,
  // it may be calling skinFactory.getSkin(...) to get hold of a base skin.
  // As SkinFactory is now under SkinProvider SPI, it makes sure that internally all parents are lazy loaded.
  // thus the caller will get a base Skin which he wants, but we do not load all skins eagerly.
  for (final Configurator config: _services)
  {
    config.reloadSkins(externalContext, skinFactory);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:19,代碼來源:GlobalConfiguratorImpl.java

示例13: TrinidadComponentHandler

import javax.faces.context.ExternalContext; //導入依賴的package包/類
public TrinidadComponentHandler(ComponentConfig config) 
{
  super(config);
  if (_markInitialState == null)
  {
    // Can't imagine why this wouldn't always run during
    // a Faces request...
    FacesContext context = FacesContext.getCurrentInstance();
    if (context != null)
    {
      ExternalContext external = context.getExternalContext();
      String restoreMode = external.getInitParameter(
                                                   StateManager.PARTIAL_STATE_SAVING_PARAM_NAME);
      
      if (Boolean.valueOf(restoreMode))
      {
        _markInitialState = Boolean.TRUE;
        _LOG.severe("PARTIAL_STATE_SAVING_NOT_SUPPORTED");
      }
      else
      {
        _markInitialState = Boolean.FALSE;
      }
    }
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:27,代碼來源:TrinidadComponentHandler.java

示例14: _getPprOptimization

import javax.faces.context.ExternalContext; //導入依賴的package包/類
/**
 * Returns the value of the PPR optimization parameter.  We currently support "on" and "off"
 * @param context
 * @return
 */
private static String _getPprOptimization(FacesContext context)
{
  ExternalContext external = context.getExternalContext();
  
  Map<String, Object> applicationMap = external.getApplicationMap();
  
  // first check if this has been overridden at the application level
  String pprOptimization = (String)applicationMap.get(_PPR_OPTIMIZATION_PROP);
  
  if (pprOptimization == null)
  {
    // the value hasn't been set, so check the initialization parameter
    pprOptimization = external.getInitParameter(_PPR_OPTIMIZATION_PROP);
    
    // default to "off"
    if (pprOptimization == null)
      pprOptimization = "off";
    
    // cache in the application so that we don't need to fetch this again
    applicationMap.put(_PPR_OPTIMIZATION_PROP, pprOptimization);
  }
  
  return pprOptimization;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:30,代碼來源:PartialPageUtils.java

示例15: construct

import javax.faces.context.ExternalContext; //導入依賴的package包/類
/**
 * This fires during the Render Response phase, saving state.
 */

public static final String construct(Object object, ExternalContext ctx)
{
    byte[] bytes = getAsByteArray(object, ctx);
    if( enableCompression(ctx) )
    {
        bytes = compress(bytes);
    }
    if(isSecure(ctx))
    {
        bytes = encrypt(bytes, ctx);
    }
    bytes = encode(bytes);
    try
    {
        return new String(bytes, ZIP_CHARSET);
    }
    catch (UnsupportedEncodingException e)
    {
        throw new FacesException(e);
    }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:26,代碼來源:StateUtils.java


注:本文中的javax.faces.context.ExternalContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。