use of javax.faces.component.UIViewRoot in project deltaspike by apache.
the class DeltaSpikePhaseListener method processPreRenderView.
private void processPreRenderView(FacesContext facesContext) {
UIViewRoot uiViewRoot = facesContext.getViewRoot();
if (uiViewRoot != null) {
ViewConfigDescriptor viewDefinitionEntry = this.viewConfigResolver.getViewConfigDescriptor(uiViewRoot.getViewId());
ViewControllerUtils.executeViewControllerCallback(viewDefinitionEntry, PreRenderView.class);
}
}
use of javax.faces.component.UIViewRoot in project oxCore by GluuFederation.
the class FacesService method renderView.
public void renderView(String viewId) {
final FacesContext ctx = FacesContext.getCurrentInstance();
final ViewHandler viewHandler = ctx.getApplication().getViewHandler();
UIViewRoot newRoot = viewHandler.createView(ctx, viewId);
updateRenderTargets(ctx, viewId);
ctx.setViewRoot(newRoot);
clearViewMapIfNecessary(ctx, viewId);
ctx.renderResponse();
}
use of javax.faces.component.UIViewRoot in project joinfaces-bean-test by larmic.
the class FacesContextMock method replaceIn.
public FacesContextMock replaceIn(ApplicationContext applicationContext) {
final FacesContext facesContext;
final ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
if (!beanFactory.containsBean("facesContext")) {
facesContext = mock(FacesContext.class);
beanFactory.registerSingleton("facesContext", facesContext);
} else {
facesContext = (FacesContext) beanFactory.getBean("facesContext");
}
final ExternalContext externalContext = mock(ExternalContext.class);
final UIViewRoot uiViewRoot = mock(UIViewRoot.class);
when(facesContext.getExternalContext()).thenReturn(externalContext);
when(externalContext.getRequestParameterMap()).thenReturn(parameterMap);
when(facesContext.getViewRoot()).thenReturn(uiViewRoot);
when(uiViewRoot.getViewMap()).thenReturn(viewMap);
final Field field;
try {
field = FacesContext.class.getDeclaredField("instance");
field.setAccessible(true);
final ThreadLocal<FacesContext> threadLocal = (ThreadLocal<FacesContext>) field.get(null);
threadLocal.set(facesContext);
} catch (Exception e) {
throw new RuntimeException(e);
}
return this;
}
use of javax.faces.component.UIViewRoot in project Payara by payara.
the class CommonHandlers method handleBareAttribute.
/**
* If the bare attribute is found in the query string and the value is "true",
* then add "bare=true" to the specified url string.
* @param url
* @return
*/
private static String handleBareAttribute(FacesContext ctx, String url) {
// Get Page Session...
UIViewRoot root = ctx.getViewRoot();
Map<String, Serializable> pageSession = PageSessionResolver.getPageSession(ctx, root);
if (pageSession == null) {
pageSession = PageSessionResolver.createPageSession(ctx, root);
}
String request = (String) ctx.getExternalContext().getRequestParameterMap().get("bare");
if (request != null) {
// It was specified, use this.
if (request.equalsIgnoreCase("true")) {
url = addQueryStringParam(url, "bare", "true");
request = "true";
} else {
request = "false";
}
pageSession.put("bare", request);
} else {
// Get the Page Session Map
Object pageSessionValue = pageSession.get("bare");
if (Boolean.TRUE.equals(pageSessionValue)) {
url = addQueryStringParam(url, "bare", "true");
} else {
pageSession.put("bare", "false");
}
}
return url;
}
use of javax.faces.component.UIViewRoot in project acs-community-packaging by Alfresco.
the class FacesHelper method getFacesContextImpl.
/**
* Return a valid FacesContext for the specific context, request and response.
* The FacesContext can be constructor for Servlet and Portlet use.
*
* @param context ServletContext or PortletContext
* @param request ServletRequest or PortletRequest
* @param response ServletReponse or PortletResponse
*
* @return FacesContext
*/
private static FacesContext getFacesContextImpl(Object request, Object response, Object context, String viewRoot) {
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
// Doesn't set this instance as the current instance of FacesContext.getCurrentInstance
FacesContext facesContext = contextFactory.getFacesContext(context, request, response, lifecycle);
// Set using our inner class
InnerFacesContext.setFacesContextAsCurrent(facesContext);
// set a new viewRoot, otherwise context.getViewRoot returns null
if (viewRoot == null) {
viewRoot = FacesHelper.BROWSE_VIEW_ID;
}
UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, viewRoot);
facesContext.setViewRoot(view);
return facesContext;
}
Aggregations