当前位置: 首页>>代码示例>>Java>>正文


Java RequestContext.getCurrentInstance方法代码示例

本文整理汇总了Java中org.apache.myfaces.trinidad.context.RequestContext.getCurrentInstance方法的典型用法代码示例。如果您正苦于以下问题:Java RequestContext.getCurrentInstance方法的具体用法?Java RequestContext.getCurrentInstance怎么用?Java RequestContext.getCurrentInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.myfaces.trinidad.context.RequestContext的用法示例。


在下文中一共展示了RequestContext.getCurrentInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeAllAsElement

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的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

示例2: getValue

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
public Object getValue(ELContext elContext, Object base, 
                       Object property)
{
  if (base == null)
  {
    if (RequestContext.VARIABLE_NAME.equals(property))
    {
      elContext.setPropertyResolved(true);
      return RequestContext.getCurrentInstance();
    }
    // Support both "pageFlowScope" and "processScope"
    // as EL variables to give developers a time to migrate
    else if (PAGE_FLOW_SCOPE_VARIABLE_NAME.equals(property) ||
           "processScope".equals(property))
    {
      elContext.setPropertyResolved(true);
      return RequestContext.getCurrentInstance().getPageFlowScope();
    }
  }
  
  return null;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:23,代码来源:TrinidadELResolver.java

示例3: _extractConverterLocale

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
private Locale _extractConverterLocale(
  FacesContext context)
{
  Locale locale = getLocale();
  if (null == locale)
  {
    RequestContext reqContext = RequestContext.getCurrentInstance();  
    if (reqContext != null)
    {
      locale = reqContext.getFormattingLocale();
    }
    if (locale == null)
    {
      locale = context.getViewRoot().getLocale();
    }
  }
  return locale;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:19,代码来源:DateTimeConverter.java

示例4: _getTimeZone

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
private TimeZone _getTimeZone()
{
  TimeZone tZone = getTimeZone();

  if (tZone == null)
  {
    RequestContext context = RequestContext.getCurrentInstance();
    if (context == null)
    {
      _LOG.warning("NO_REQUESTCONTEXT_TIMEZONE_DEFAULT");
    }
    else
    {
      tZone = context.getTimeZone();
    }

    // If RequestContext is null or if it returns a null,
    // then set it to the default time zone which is GMT time zone
    if (tZone == null)
    {
      tZone = _DEFAULT_TIME_ZONE;
    }
  }

  return tZone;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:27,代码来源:DateTimeConverter.java

示例5: _getISOFormat

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
private SimpleDateFormat _getISOFormat (Converter conv)
{
  SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  // Trinidad-1967: ISOFormat should use the same timezone as the converter's
  // Make sure this matches DateTimeConverter's#_getTimeZone
  TimeZone tZone = null;

  if (conv instanceof javax.faces.convert.DateTimeConverter)
     tZone = ((javax.faces.convert.DateTimeConverter)conv).getTimeZone();
   
  if (tZone == null)
  {
    RequestContext context = RequestContext.getCurrentInstance();
    if (context == null)
    {
      _LOG.warning("NO_REQUESTCONTEXT_TIMEZONE_DEFAULT");
    }
    else
    {
      tZone = context.getTimeZone();
    }

    // If RequestContext is null or if it returns a null,
    // then set it to the default time zone which is GMT time zone
    if (tZone == null)
    {
      tZone = _DEFAULT_TIME_ZONE;
    }
  }
  isoFormat.setTimeZone(tZone);
  return isoFormat;    
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:33,代码来源:DateTimeRangeValidator.java

示例6: ReplyToMessageBackingBean

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
public ReplyToMessageBackingBean()
{
  // if the user pressed the Reply button, then the pageFlowScope's
  // replyToAll value will be false. If the user pressed the
  // Reply to All button, then the pageFlowScope's replyToAll value
  // will be true. We set this in the showMessage.jspx page.
  RequestContext afContext = RequestContext.getCurrentInstance();

  Object replyToAll = afContext.getPageFlowScope().get("replyToAll");

  _setUpReplyToMessage("true".equals(replyToAll));
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:13,代码来源:ReplyToMessageBackingBean.java

示例7: getActionURL

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
@Override
public String getActionURL(FacesContext context, String viewId)
{
  String actionURL = super.getActionURL(context, viewId);
  RequestContext afContext = RequestContext.getCurrentInstance();
  if (afContext != null)
  {
    actionURL = afContext.getPageResolver().encodeActionURI(actionURL);
    actionURL = afContext.getPageFlowScopeProvider().
                   encodeCurrentPageFlowScopeURL(context, actionURL);
  }

  return actionURL;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:15,代码来源:ViewHandlerImpl.java

示例8: _getWrongMonthMessage

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
/**
 * Builds an error message indicating invalid month selection
 * @param context FacesContext
 * @param component inputDate instance
 * @param converter date converter instance
 * @param value user submitted value
 * @param monthIndex Month index as returned by Calendar.MONTH on the value
 * @return FacesMessage
 */
private FacesMessage _getWrongMonthMessage(
  FacesContext  context,
  UIComponent   component,
  Converter     converter,
  Object        value,
  int           monthIndex)
{ 
  RequestContext reqContext = RequestContext.getCurrentInstance();  
  Locale locale = reqContext.getFormattingLocale();

  if (locale == null)
  {
    locale = context.getViewRoot().getLocale();
  }
  
  Object cValue = _getConvertedValue(context, component, converter, value);

  Object msg   = _getRawInvalidMonthMessageDetail();
  Object label = ValidatorUtils.getComponentLabel(component);
  
  // Fetch the localized month name 
  String[] months = new DateFormatSymbols(locale).getMonths();

  Object[] params = {label, cValue, months[monthIndex]};

  return MessageFactory.getMessage(context, MONTH_MESSAGE_ID, msg, params, component);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:37,代码来源:DateRestrictionValidator.java

示例9: encodeEnd

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
@Override
public void encodeEnd(FacesContext context) throws IOException
{
  if (context == null)
    throw new NullPointerException();

  try
  {
  if (isRendered())
  {
    RequestContext requestContext = RequestContext.getCurrentInstance();
    requestContext.pushCurrentComponent(context, this);

    try
    {
      Renderer renderer = getRenderer(context);
      // if there is a Renderer for this component
      if (renderer != null)
      {
        renderer.encodeEnd(context, this);
      }
    }
    finally
    {
      requestContext.popCurrentComponent(context, this);
    }
  }
}
  finally
  {
    popComponentFromEL(context);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:34,代码来源:UIXComponentBase.java

示例10: doLaunch

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
public String doLaunch()
{
  RequestContext afContext = RequestContext.getCurrentInstance();
  Map<String, Object> process = afContext.getPageFlowScope();
  process.put("lastLaunch", new Date());

  return "dialog:chooseInteger";
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:9,代码来源:LaunchDialogBean.java

示例11: ShowMessageBackingBean

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
public ShowMessageBackingBean()
{
  // Code necessary because of:
  //   https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=22
  RequestContext afContext = RequestContext.getCurrentInstance();
  setMessage((MessageData) afContext.getPageFlowScope().get("message"));
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:8,代码来源:ShowMessageBackingBean.java

示例12: getResource

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
@Override
public URL getResource(String path)
                         throws MalformedURLException
{
  RequestContext afc = RequestContext.getCurrentInstance();
  if (afc != null)
  {
    path = afc.getPageResolver().getPhysicalURI(path);
  }
  return super.getResource(path);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:12,代码来源:FacesContextFactoryImpl.java

示例13: handleNavigation

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
@Override
public void handleNavigation(
  FacesContext context,
  String       fromAction,
  String       outcome)
{
  if (_disableNavigationHandler(context))
  {
    _delegate.handleNavigation(context, fromAction, outcome);
    return;
  }
 
  RequestContext afc = RequestContext.getCurrentInstance();
  
  // We are interested for "dialog:" prefixed outcomes 
  if ((outcome != null) && (outcome.startsWith(afc.getDialogService().getDialogNavigationPrefix())))
  {
    // Handle "dialog:" URLs
    
    // First we try find a classic navigation case from faces-config.xml
    NavigationCase navigationCase = getNavigationCase(context, fromAction, outcome);
    
    // Then if there is no rule (but we are in dialog here) try interpret 
    // outcome as view id - JSF 2.0 Implicit Navigation.
    if (navigationCase == null)
    {
      navigationCase = getNavigationCase(context, fromAction, 
          outcome.substring(afc.getDialogService().getDialogNavigationPrefix().length()));
    } 
    
    UIViewRoot newRoot = null;
    UIViewRoot oldRoot = context.getViewRoot();
    
    if (navigationCase == null)
    {
      // Execute the old (pre-ConfigurableNavigation) code in case the navigation case
      // could not be determined
      
      // ViewMap is cleared during navigation, so save it here (we will be undoing the navigation
      // by restoring the old view root below)
      Map<String,Object> viewMap = oldRoot.getViewMap(false);
      Map<String,Object> cloneMap = (viewMap == null) ? null : new HashMap<String, Object>(viewMap);
      
      _delegate.handleNavigation(context, fromAction, outcome);
      
      newRoot = context.getViewRoot();
      
      if (newRoot != oldRoot)
      {
        // Navigate back to the original root
        context.setViewRoot(oldRoot);
        
        // Restore the old ViewMap because it gets cleared during setViewRoot()
        if (cloneMap != null)
        {
          oldRoot.getViewMap().putAll(cloneMap);
        }
      }
    }
    else
    {
      newRoot = context.getApplication().getViewHandler().createView(context, navigationCase.getToViewId(context));
    }
   
    if (newRoot != oldRoot)
    {
      // Give ourselves a new page flow scope
      afc.getPageFlowScopeProvider().pushPageFlowScope(context, true);
      // And ask the component to launch a dialog
      afc.getDialogService().queueLaunchEvent(newRoot);
    }
  }
  else
  {
     // not a dialog, call the wrapped NavigationHandler
    _delegate.handleNavigation(context, fromAction, outcome);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:79,代码来源:NavigationHandlerImpl.java

示例14: decode

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void decode(
  FacesContext facesContext,
  UIComponent  component,
  @SuppressWarnings("unused")
  FacesBean    facesBean,
  String       clientId)
{
  Map<String, String> parameters =
    facesContext.getExternalContext().getRequestParameterMap();

  Object event = parameters.get(XhtmlConstants.EVENT_PARAM);
  if (XhtmlConstants.HIDE_EVENT.equals(event) ||
      XhtmlConstants.SHOW_EVENT.equals(event))
  {
    Object source = parameters.get(XhtmlConstants.SOURCE_PARAM);
    String id = clientId == null ? component.getClientId(facesContext) : clientId;

    if (id.equals(source))
    {
      boolean isDisclosed = XhtmlConstants.SHOW_EVENT.equals(event);
      String itemId = parameters.get("targetItem");
      if (itemId != null)
      {
        List<UIComponent> children = component.getChildren();
        for (UIComponent child : children)
        {
          if (!(child instanceof UIXShowDetail))
            continue;

          // Don't even bother with disabled showDetailItems -
          // a malicious user should not be able to force
          // a disabled item open by dummying up an event
          if (!child.isRendered() || _isItemDisabled(child))
            continue;

          if (itemId.equals(child.getClientId(facesContext)))
          {
            (new DisclosureEvent(child, isDisclosed)).queue();
            RequestContext rc = RequestContext.getCurrentInstance();

            // Don't force PPR on for the browsers that do not support Ajax
            Object cap = rc.getAgent().getCapabilities().get(TrinidadAgent.CAP_PARTIAL_RENDERING);
            if ((cap != null) && (Boolean.TRUE.equals(cap)))
            {
              RequestContext.getCurrentInstance().addPartialTarget(component);
              PartialPageUtils.forcePartialRendering(facesContext);
            }

            break;
          }
        }
      }
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:58,代码来源:PanelAccordionRenderer.java

示例15: broadcast

import org.apache.myfaces.trinidad.context.RequestContext; //导入方法依赖的package包/类
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException
{
  // Perform special processing for ActionEvents:  tell
  // the RequestContext to remember this command instance
  // so that the NavigationHandler can locate us to queue
  // a LaunchEvent.
  if (event instanceof ActionEvent)
  {
    RequestContext afContext = RequestContext.getCurrentInstance();
    afContext.getDialogService().setCurrentLaunchSource(this);

    try
    {
      // Perform standard superclass processing
      super.broadcast(event);

      // Notify the specified action listener method (if any),
      // and the default action listener
      broadcastToMethodBinding(event, getActionListener());

      FacesContext context = getFacesContext();
      ActionListener defaultActionListener =
        context.getApplication().getActionListener();
      if (defaultActionListener != null)
      {
        defaultActionListener.processAction((ActionEvent) event);
      }
    }
    finally
    {
      afContext.getDialogService().setCurrentLaunchSource(null);
    }
  }
  else
  {
    // Perform standard superclass processing
    super.broadcast(event);

    if (event instanceof LaunchEvent)
    {
      broadcastToMethodExpression(event, getLaunchListener());
      boolean useWindow = 
        Boolean.TRUE.equals(getAttributes().get("useWindow"));

      ((LaunchEvent) event).launchDialog(useWindow);
    }
    else if (event instanceof ReturnEvent)
    {
      broadcastToMethodExpression(event, getReturnListener());
      // =-=AEW: always jump to render response???  Seems the safest
      // option, because we don't want to immediately update a model
      // or really perform any validation.
      getFacesContext().renderResponse();
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:58,代码来源:UIXCommandTemplate.java


注:本文中的org.apache.myfaces.trinidad.context.RequestContext.getCurrentInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。