use of com.github.bordertech.wcomponents.WApplication in project wcomponents by BorderTech.
the class AbstractContainerHelper method render.
/**
* Support standard processing of the render phase of a request.
*
* @throws IOException IO Exception
*/
public void render() throws IOException {
if (isDisposed()) {
LOG.debug("Skipping render phase.");
return;
}
try {
// Check user context has been prepared
if (getNewConversation() == null) {
throw new IllegalStateException("User context has not been prepared before the render phase");
}
prepareRender();
UIContext uic = getUIContext();
if (uic == null) {
throw new IllegalStateException("No user context set for the render phase.");
}
UIContextHolder.pushContext(uic);
prepareRequest();
// Handle errors from the action phase now.
if (havePropogatedError()) {
handleError(getPropogatedError());
return;
}
WComponent uiComponent = getUI();
if (uiComponent == null) {
throw new SystemException("No UI Component exists.");
}
Environment environment = uiComponent.getEnvironment();
if (environment == null) {
throw new SystemException("No WEnvironment exists.");
}
getInterceptor().attachResponse(getResponse());
getInterceptor().preparePaint(getRequest());
String contentType = getUI().getHeaders().getContentType();
Response response = getResponse();
response.setContentType(contentType);
addGenericHeaders(uic, getUI());
PrintWriter writer = getPrintWriter();
getInterceptor().paint(new WebXmlRenderContext(writer, uic.getLocale()));
// The following only matters for a Portal context
String title = uiComponent instanceof WApplication ? ((WApplication) uiComponent).getTitle() : null;
if (title != null) {
setTitle(title);
}
} catch (Escape esc) {
LOG.debug("Escape performed during render phase.");
handleEscape(esc);
} catch (Throwable t) {
// We try not to let any exception propagate to container.
String message = "Caught exception during render phase.";
LOG.error(message, t);
handleError(t);
} finally {
UIContextHolder.reset();
dispose();
}
}
use of com.github.bordertech.wcomponents.WApplication in project wcomponents by BorderTech.
the class DynamicLauncher method setComponentToLaunch.
/**
* <p>
* Set the instance for the UI to launch.</p>
* <p>
* A null value will revert to the Default PlainLauncher parameter behavior.
* </p>
*
* @param uniqueId the uniqueId to register the component.
* @param componentToLaunch the WComponent to launch.
* @return the registered component as a singleton.
*/
public WApplication setComponentToLaunch(final String uniqueId, final WApplication componentToLaunch) {
setCurrentKey(uniqueId);
// Check if already registered
WApplication appl = getRegisteredComponent(uniqueId);
if (appl != null) {
return appl;
}
// Register the componenent
registerComponent(uniqueId, componentToLaunch);
return componentToLaunch;
}
use of com.github.bordertech.wcomponents.WApplication in project wcomponents by BorderTech.
the class SimplePicker method updateTitle.
/**
* Updates the title, based on the selected example.
*/
private void updateTitle() {
String title;
if (this.getCurrentComponent() == null) {
title = "Example Picker";
} else {
title = this.getCurrentComponent().getClass().getName();
}
WApplication app = WebUtilities.getAncestorOfClass(WApplication.class, this);
if (app != null) {
app.setTitle(title);
}
}
use of com.github.bordertech.wcomponents.WApplication in project wcomponents by BorderTech.
the class TreeUtil_Test method initTree.
@Before
public void initTree() {
root = new WApplication();
containerChild = new WContainer();
simpleChild = new WTextField();
repeatedComponent = new WText();
repeaterChild = new WRepeater(repeatedComponent);
grandChild = new WTextArea();
cardManager = new WCardManager();
card1 = new WText();
card2 = new WText();
root.add(containerChild);
root.add(simpleChild);
root.add(repeaterChild);
root.add(cardManager);
containerChild.add(grandChild);
cardManager.add(card1);
cardManager.add(card2);
root.setLocked(true);
setActiveContext(new UIContextImpl());
repeaterChild.setData(Arrays.asList(new String[] { "1", "2", "3" }));
}
use of com.github.bordertech.wcomponents.WApplication in project wcomponents by BorderTech.
the class ServerCache method wrapUI.
/**
* @param ui the UI component
* @return the UI component wrapped in WApplication
*/
private static WApplication wrapUI(final WComponent ui) {
WApplication egUI;
if (ui instanceof WApplication) {
egUI = (WApplication) ui;
} else {
egUI = new WApplication();
egUI.add(ui);
}
return egUI;
}
Aggregations