use of javax.faces.component.UIViewRoot in project acs-community-packaging by Alfresco.
the class InvokeCommand method setupResponseWriter.
/**
* setup the JSF response writer.
*/
private ResponseWriter setupResponseWriter(final String mimetype, final HttpServletResponse response, final FacesContext facesContext) throws IOException {
final OutputStream os = response.getOutputStream();
final UIViewRoot viewRoot = facesContext.getViewRoot();
final RenderKitFactory renderFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
final RenderKit renderKit = renderFactory.getRenderKit(facesContext, viewRoot.getRenderKitId());
final ResponseWriter writer = renderKit.createResponseWriter(new OutputStreamWriter(os, "UTF-8"), mimetype, "UTF-8");
facesContext.setResponseWriter(writer);
// must be text/xml otherwise IE doesn't parse the response properly into responseXML
response.setContentType(mimetype);
return writer;
}
use of javax.faces.component.UIViewRoot in project rubia-forums by flashboss.
the class ForumUtil method getToHTMLRenderer.
/**
* @param req
* the request that maybe contains the format object
* @return the renderer for the requested request
*/
private static ToHTMLRenderer getToHTMLRenderer(Object req) {
ToHTMLRenderer renderer = null;
// TODO: GETTING RENDERER FROM APPLICATION SCOPE ATTRIBUTE
if (renderer == null) {
// Getting ResourceBundle with current Locale
FacesContext ctx = getCurrentInstance();
UIViewRoot uiRoot = ctx.getViewRoot();
Locale locale = uiRoot.getLocale();
ClassLoader ldr = currentThread().getContextClassLoader();
ResourceBundle bundle = getBundle("ResourceJSF", locale, ldr);
// Create the HTMLRenderer for BBCode
ToHTMLConfig config = new ToHTMLConfig();
renderer = new ToHTMLRenderer(config, bundle);
}
return renderer;
}
use of javax.faces.component.UIViewRoot in project rubia-forums by flashboss.
the class NotificationEngineImpl method schedule.
public void schedule(Integer postId, int mode, String absViewURL, String absReplyURL) {
try {
if (postId == null || mode == -1) {
return;
}
// Getting ResourceBundle with current Locale
// Too bad for now we support notifications sent in the locale of
// the poster :-(
UIViewRoot uiRoot = getCurrentInstance().getViewRoot();
Locale locale = uiRoot.getLocale();
ClassLoader ldr = Thread.currentThread().getContextClassLoader();
ResourceBundle bundle = ResourceBundle.getBundle("ResourceJSF", locale, ldr);
// Create task
NotificationTask task = new NotificationTask(absViewURL, absReplyURL, postId, mode, bundle);
// Register at the end of the current tx to broadcast notifications
Transaction tx = tm.getTransaction();
tx.registerSynchronization(task);
} catch (Exception e) {
log.error(e);
}
}
use of javax.faces.component.UIViewRoot in project rubia-forums by flashboss.
the class BackButton method afterPhase.
@Override
public void afterPhase(PhaseEvent arg0) {
FacesContext facesContext = arg0.getFacesContext();
UIViewRoot uiViewRoot = facesContext.getViewRoot();
if (getCancelButton(uiViewRoot) != null)
facesContext.getViewRoot().setViewId(oldViewId);
}
use of javax.faces.component.UIViewRoot in project rubia-forums by flashboss.
the class BackButton method beforePhase.
@Override
public void beforePhase(PhaseEvent arg0) {
FacesContext facesContext = arg0.getFacesContext();
UIViewRoot uiViewRoot = facesContext.getViewRoot();
if (getCancelButton(uiViewRoot) == null)
oldViewId = uiViewRoot.getViewId();
}
Aggregations