本文整理匯總了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});
}
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
}