use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class ContextCleanupInterceptor method paint.
/**
* Override paint to clear out the scratch map and component models which are no longer necessary.
*
* @param renderContext the renderContext to send the output to.
*/
@Override
public void paint(final RenderContext renderContext) {
super.paint(renderContext);
UIContext uic = UIContextHolder.getCurrent();
if (LOG.isDebugEnabled()) {
UIContextDebugWrapper debugWrapper = new UIContextDebugWrapper(uic);
LOG.debug("Session usage after paint:\n" + debugWrapper);
}
LOG.debug("Performing session tidy up of WComponents (any WComponents disconnected from the active top component will not be tidied up.");
getUI().tidyUpUIContextForTree();
LOG.debug("After paint - Clearing scratch maps.");
uic.clearScratchMap();
uic.clearRequestScratchMap();
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class DefaultPageShell method writeHeader.
/**
* {@inheritDoc}
*/
@Override
public void writeHeader(final PrintWriter writer) {
UIContext uic = UIContextHolder.getCurrent();
addHeadlines(writer, uic.getHeaders().getHeadLines());
addJsHeadlines(writer, uic.getHeaders().getHeadLines(Headers.JAVASCRIPT_HEADLINE));
addCssHeadlines(writer, uic.getHeaders().getHeadLines(Headers.CSS_HEADLINE));
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class FormInterceptor method paint.
/**
* Override paint in order to perform processing specific to this interceptor.
*
* @param renderContext the renderContext to send the output to.
*/
@Override
public void paint(final RenderContext renderContext) {
getBackingComponent().paint(renderContext);
// We don't want to remember the focus for the next render because on
// a multi portlet page, we'd end up with multiple portlets trying to
// set the focus.
UIContext uic = UIContextHolder.getCurrent();
if (uic.isFocusRequired()) {
boolean sticky = ConfigurationProperties.getStickyFocus();
if (!sticky) {
uic.setFocussed(null, null);
uic.setFocusRequired(false);
}
}
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class SessionTokenAjaxInterceptor method serviceRequest.
/**
* Override to check whether the session token variable in the incoming request matches what we expect.
*
* @param request the request being serviced.
*/
@Override
public void serviceRequest(final Request request) {
// Get the expected session token
UIContext uic = UIContextHolder.getCurrent();
String expected = uic.getEnvironment().getSessionToken();
// Session token should already be set
if (expected == null) {
LOG.error("Session token should already be set on the session before AJAX request. Can be due to the session timing out.");
handleError();
}
// Get the session token from the request
String got = request.getParameter(Environment.SESSION_TOKEN_VARIABLE);
// Check tokens match (both must be provided)
if (Util.equals(expected, got)) {
// Process Service Request
getBackingComponent().serviceRequest(request);
} else {
// Invalid token
LOG.error("Wrong session token detected for AJAX request. Expected token [" + expected + "] but got token [" + got + "].");
handleError();
}
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class SessionTokenContentInterceptor method serviceRequest.
/**
* Override to check whether the session token variable in the incoming request matches what we expect.
*
* @param request the request being serviced.
*/
@Override
public void serviceRequest(final Request request) {
// Get the expected session token
UIContext uic = UIContextHolder.getCurrent();
String expected = uic.getEnvironment().getSessionToken();
// Session token should already be set
if (expected == null) {
LOG.error("Session token should already be set on the session before content request. Can be due to the session timing out.");
handleError();
}
// Get the session token from the request
String got = request.getParameter(Environment.SESSION_TOKEN_VARIABLE);
// Check tokens match (both must be provided)
if (Util.equals(expected, got)) {
// Process Service Request
getBackingComponent().serviceRequest(request);
} else if (got == null && StepCountUtil.isCachedContentRequest(request)) {
// Check cached content (no session token on request)
// Process Service Request
getBackingComponent().serviceRequest(request);
} else {
// Invalid token
// Set an error code
LOG.warn("Wrong session token detected for content request. Expected token [" + expected + "] but got token [" + got + "].");
handleError();
}
}
Aggregations