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


Java FacesContext.getViewRoot方法代码示例

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


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

示例1: _logStaleParentAtLevel

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * Logs a message at a specified level when a stale component is detected during create component.
 * @param context FacesContext
 * @param child the UIComponent being created
 * @param oldParent the parent UIComponent
 * @param level the level at which to log the message
 */
private void _logStaleParentAtLevel(FacesContext context,
                                    UIComponent child,
                                    UIComponent oldParent,
                                    Level level)
{
  if (_LOG.isLoggable(level))
  {
    UIViewRoot viewRoot = context.getViewRoot();

    String scopedId = ComponentUtils.getScopedIdForComponent(child, viewRoot);
    String oldParentScopedId = ComponentUtils.getScopedIdForComponent(oldParent, viewRoot);
    String newParentScopedId = _getParentScopedId(viewRoot);

    String bindingEL = _getBindingExpression();

    _LOG.log(level, "ERROR_CREATE_COMPONENT_STALE",
                new Object[] {scopedId, oldParentScopedId, newParentScopedId, bindingEL});
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:27,代码来源:UIXComponentELTag.java

示例2: getRenderKit

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
static public RenderKit getRenderKit(FacesContext context)
{
  RenderKitFactory factory = (RenderKitFactory)
    FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);

  factory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, new BasicHtmlRenderKit());

  String renderKitId = null;
  if (context.getViewRoot() != null)
    renderKitId = context.getViewRoot().getRenderKitId();
  if (renderKitId == null)
    renderKitId = "org.apache.myfaces.trinidad.core";

  RenderKit renderKit = factory.getRenderKit(context,renderKitId);
  if (renderKit == null)
    throw new IllegalStateException("Could not create renderKit " + renderKitId);

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

示例3: addComponentChange

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void addComponentChange(
  FacesContext facesContext,
  UIComponent uiComponent,
  ComponentChange change)
{
  // if our component is a stamped component by UIXIterator, we 
  // don't want to persist the changes 
  UIComponent parent = uiComponent.getParent();
  UIComponent root = facesContext.getViewRoot();
  while (parent != null && parent != root)
  {
    if (parent.getClass() == UIXIterator.class) 
    {
      _LOG.info("DONT_PERSIST_STAMPED_COMPONENT_INSIDE_ITERATOR");      
      return;
    }
    parent = parent.getParent();      
  }
      
  if (facesContext == null || uiComponent == null || change == null)
    throw new IllegalArgumentException(_LOG.getMessage(
      "CANNOT_ADD_CHANGE_WITH_FACECONTEXT_OR_UICOMPONENT_OR_NULL"));

  // add the change to the component
  addComponentChangeImpl(facesContext, uiComponent, change);

  // add a corresponding DocumentChange if possible
  _addEquivalentDocumentChange(facesContext, uiComponent, change);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:34,代码来源:BaseChangeManager.java

示例4: afterPhase

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
public void afterPhase(PhaseEvent arg0) {
	FacesContext facesContext = arg0.getFacesContext();
	UIViewRoot uiViewRoot = facesContext.getViewRoot();
	if (getCancelButton(uiViewRoot) != null)
		facesContext.getViewRoot().setViewId(oldViewId);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:8,代码来源:BackButton.java

示例5: beforePhase

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
public void beforePhase(PhaseEvent arg0) {
	FacesContext facesContext = arg0.getFacesContext();
	UIViewRoot uiViewRoot = facesContext.getViewRoot();
	if (getCancelButton(uiViewRoot) == null)
		oldViewId = uiViewRoot.getViewId();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:8,代码来源:BackButton.java

示例6: getConverter

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * Getting converter with needed local.
 * 
 * @param context
 *            JSF context.
 * @return Instance of old price converter. TODO Refactor all code for using
 *         only UI conversion.
 */
private PriceConverter getConverter(FacesContext context) {
    Locale locale;
    if (context.getViewRoot() != null) {
        locale = context.getViewRoot().getLocale();
    } else {
        locale = context.getApplication().getDefaultLocale();
    }
    final PriceConverter converter = new PriceConverter(locale);

    return converter;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:CurrencyConverter.java

示例7: getViewMap

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Map<String, Object> getViewMap(boolean create)
{
  // Note: replace this method body with a call to UIViewRoot.getViewMap(boolean) when
  // Trinidad is upgraded to use JSF 2.0

  FacesContext facesContext = FacesContext.getCurrentInstance();
  UIViewRoot viewRoot = facesContext.getViewRoot();
  Map<String, Object> viewMap = null;

  if (viewRoot != null)
  {
    Map<String, Object> attrs = viewRoot.getAttributes();

    viewMap = (Map<String, Object>)attrs.get(_VIEW_MAP_KEY);
    if (viewMap == null && create)
    {
      // Note, it is not valid to refer to the request context from outside of the request's
      // thread. As such, synchronization and thread safety is not an issue here.
      // This coincides with the JSF 2.0 code not using syncronization and using the non-thread
      // safe HashMap.
      viewMap = new HashMap<String, Object>();
      attrs.put(_VIEW_MAP_KEY, viewMap);
    }
  }

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

示例8: _getPath

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * Return the physical path of a particular URI
 */
static private String _getPath(FacesContext context, String uri)
{
  UIViewRoot viewRoot = context.getViewRoot();
  boolean viewMatch = false;
  Map<String, String> viewIdMap = (Map<String, String>)context.getAttributes().get(_VIEWID_MAPPING);
  if (viewRoot != null && viewRoot.getViewId().equals(uri))
  {
    viewMatch = true;
    // Only return from cache if requested for the current viewRoot and it matches the arg. 
    // Same rule applies when storing into viewMap
    if (viewIdMap != null)
    {
      String cachedPhysicalURI = viewIdMap.get(uri);
      if (cachedPhysicalURI != null)
        return cachedPhysicalURI;
    }
  }
  
  RequestContext afc = RequestContext.getCurrentInstance();
  if (afc != null)
  {
    String physicalURI = afc.getPageResolver().getPhysicalURI(uri);
    if (viewMatch)
    {
      // Store the viewId 
      if (viewIdMap == null)
      {
        viewIdMap = new HashMap<String, String>();
        context.getAttributes().put(_VIEWID_MAPPING, viewIdMap);
      }
      viewIdMap.put(uri, physicalURI);
    }
    return physicalURI;
  }

  // No RequestContext?  Just return the URI
  return uri;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:42,代码来源:ViewDeclarationLanguageFactoryImpl.java

示例9: _defaultCreateView

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private UIViewRoot _defaultCreateView(FacesContext context, String viewId)
{
  UIViewRoot result = (UIViewRoot) context.getApplication()
                          .createComponent(UIViewRoot.COMPONENT_TYPE);
  
  Locale locale = null;
  String renderKitId = null;
  
  // use the locale from the previous view if is was one which will be
  // the case if this is called from NavigationHandler. There wouldn't be
  // one for the initial case.
  if (context.getViewRoot() != null) 
  {
    locale = context.getViewRoot().getLocale();
    renderKitId = context.getViewRoot().getRenderKitId();
  }
  
  if (locale == null) 
  {
    locale = context.getApplication().getViewHandler().calculateLocale(context);
  }
  
  if (renderKitId == null) 
  {
    renderKitId = context.getApplication().getViewHandler().calculateRenderKitId(context);
  }
  
  result.setLocale(locale);
  result.setRenderKitId(renderKitId);
  result.setViewId(viewId);

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

示例10: _logSevereTagProcessingError

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * Logs a severe warning when an exception is thrown during component tag processing.
 * @param methodName name of the method throwing the exception
 * @param e Throwable
 */
private void _logSevereTagProcessingError(FacesContext context, Throwable e)
{
  UIViewRoot viewRoot = context.getViewRoot();
  UIComponent component = this.getComponentInstance();
  String scopedId = _getScopedId(component, viewRoot);
  String parentScopedId = _getParentScopedId(viewRoot);

  String message = _LOG.getMessage("ERROR_PARSING_COMPONENT_TAG",
                                   new Object[] {scopedId, parentScopedId});
  _LOG.severe(message, e);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:17,代码来源:UIXComponentELTag.java

示例11: getId

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * Gets the identifier for the component.  This implementation
 * never returns a null id.
 */
@Override
public String getId()
{
  // determine whether we can use the optimized code path or not
  if (_usesFacesBeanImpl)
  {
    // optimized path

    // make sure that we always have an id
    if (_id == null)
    {
      FacesContext context = FacesContext.getCurrentInstance();
      UIViewRoot viewRoot = context.getViewRoot();

      _id = viewRoot.createUniqueId();
    }

    return _id;
  }
  else
  {
    // unoptimized path
    FacesBean facesBean = getFacesBean();

    String id = (String)facesBean.getProperty(ID_KEY);

    // make sure that we always have an id
    if (id == null)
    {
      id = FacesContext.getCurrentInstance().getViewRoot().createUniqueId();

      facesBean.setProperty(ID_KEY, id);
    }

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

示例12: isPostback

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
public boolean isPostback()
{
  FacesContext context = __getFacesContext();
  // First, see if this is definitely not a postback request
  if (!TrinidadPhaseListener.isPostback(context))
    return false;

  // Second, see if we are still on the original view root (which
  // the PhaseListener's isPostback() method doesn't look at).
  UIViewRoot originalViewRoot = (UIViewRoot)
    context.getExternalContext().getRequestMap().
       get(TrinidadPhaseListener.INITIAL_VIEW_ROOT_KEY);

  // However, we only set the "originalViewRoot" during the afterPhase()
  // of our PhaseListener;  so, if it's null, then we have to asume
  // that we have yet to even reach this code, as in, for example,
  // an afterPhase() phase listener method for Restore View that happens
  // to run before ours (which happens if it's registered *after* ours,
  // because afterPhase() runs in inverse order).  If so, there certainly
  // hasn't been any navigation, so consider it a postback request.
  if ((originalViewRoot != null) &&
      (originalViewRoot != context.getViewRoot()))
    return false;

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

示例13: teste

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void teste() {
    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot viewRoot = context.getViewRoot();
    DataTable dataTable = (DataTable) viewRoot.findComponent("Rel:tabelaRelatorio");
    dataTable.setValue(null);
    dataTable.setColumns(null);
    Validacao.AtualizarCompoente("Rel", "tabelaRelatorio");
    String tipoRelatorio = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("relatorio");
    relatorio.setTipoRelatorio(tipoRelatorio);
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:11,代码来源:RelatorioBean.java

示例14: isInternalViewRequest

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
public boolean isInternalViewRequest(FacesContext context)
{
  UIViewRoot root = context.getViewRoot();
  if (root == null)
    return false;

  ViewDeclarationLanguage strategy = context.getApplication().
                        getViewHandler().getViewDeclarationLanguage(context, root.getViewId());

  return (strategy instanceof InternalViewHandlingStrategy);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:13,代码来源:RequestContextImpl.java

示例15: encodeComponentResources

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * Hook for rendering the component resources for the <code>target</code>.
 * @param context Current <code>FacesContext</code> object for this request.
 * @param target The target for the resources (e.g. head/body/form)
 *
 * @throws IOException
 */
protected final void encodeComponentResources(
  FacesContext context,
  String       target
  ) throws IOException
{
  if(target != null)
  {
    UIViewRoot viewRoot = context.getViewRoot();
    for(UIComponent componentResource : viewRoot.getComponentResources(context, target))
    {
      componentResource.encodeAll(context);
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:22,代码来源:CoreRenderer.java


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