Temporarily replaces the environment while the UI prepares to render.

@param request the request being responded to.
541601
@Override
	public void preparePaint(final Request request) {
		if (windowId == null) {
			super.preparePaint(request);
		} else {
			// Get the window component
			ComponentWithContext target = WebUtilities.getComponentById(windowId, true);
			if (target == null) {
				throw new SystemException("No window component for id " + windowId);
			}

			UIContext uic = UIContextHolder.getCurrentPrimaryUIContext();
			Environment originalEnvironment = uic.getEnvironment();
			uic.setEnvironment(new EnvironmentDelegate(originalEnvironment, windowId, target));

			UIContextHolder.pushContext(target.getContext());
			try {
				super.preparePaint(request);
			} finally {
				uic.setEnvironment(originalEnvironment);
				UIContextHolder.popContext();
			}
		}
	}
1211568
private void addPostParams(final Request request) {
        if (path != null) {
            request.addPostParam("Path", path);
        }

        if (visibility != null) {
            request.addPostParam("Visibility", visibility.toString());
        }
    }
438396
@Override
	public void preparePaintComponent(final Request request) {
		if (!this.isInitialised()) {
			List<String> dummyList = new ArrayList<>(2);
			dummyList.add("a");
			dummyList.add("b");

			repeater.setData(dummyList);

			this.setInitialised(true);
		}
	}
85020
@Override
	public void preparePaintComponent(final Request request) {
		if (!this.isInitialised()) {
			// Give the repeater the list of data to display.
			repeater.setData(fetchDataList());

			// Remember that we've done the initialisation.
			this.setInitialised(true);
		}
	}
975255
void afterTerminate(HttpRequest<?> request) {
        Optional<Tracer.SpanInScope> scope = request.removeAttribute(
                TraceRequestAttributes.CURRENT_SCOPE,
                Tracer.SpanInScope.class
        );
        scope.ifPresent(Tracer.SpanInScope::close);
    }
244354
public void deselect(DeselectRequest request) {
    call(
      new PostRequest(path("deselect"))
        .setParam("organization", request.getOrganization())
        .setParam("projectId", request.getProjectId())
        .setParam("projectKey", request.getProjectKey())
        .setMediaType(MediaTypes.JSON)
    ).content();
  }
229587
@Override
	protected void preparePaintComponent(final Request request) {
		super.preparePaintComponent(request);

		if (!isInitialised()) {
			tf3.setText("This is read only.");
			tf4.setText("This is disabled.");
			readFields();
			setInitialised(true);
		}
	}
1338861
private void handlePaginationRequest(final Request request) {
		String pageStr = request.getParameter(getId() + ".page");

		if (pageStr == null) {
			setCurrentPage(0);
		} else {
			try {
				int pageNum = Integer.parseInt(pageStr);
				setCurrentPage(pageNum);
			} catch (NumberFormatException e) {
				LOG.warn("Invalid page number: " + pageStr);
			}
		}
	}
895272
private void addPostParams(final Request request) {
        if (defaults != null) {
            request.addPostParam("Defaults", Converter.mapToJson(defaults));
        }
    }
248265
@Override
	public void preparePaintComponent(final Request request) {
		String dateStr = "The current date is " + new Date();
		dynamicText.setText(dateStr);
	}
982659
@Override
	protected void preparePaintComponent(final Request request) {
		super.preparePaintComponent(request);

		if (!isInitialised()) {
			updateRecentMenu();
			setInitialised(true);
		}

		boolean hasRecentMenu = menu.getMenuItems().size() > 0;
		menu.setVisible(hasRecentMenu);
		recentMenuHeading.setVisible(hasRecentMenu);
	}
1295328
@Override
	protected void preparePaintComponent(final Request request) {
		super.preparePaintComponent(request);

		// Check if window in request (might not have gone through handle request, eg Step error)
		boolean targeted = isPresent(request);
		setTargeted(targeted);

		if (getState() == ACTIVE_STATE && isTargeted()) {
			getComponentModel().wrappedContent.preparePaint(request);
		}
	}
1174440
private void addPostParams(final Request request) {
        if (styleSheet != null) {
            request.addPostParam("StyleSheet", Converter.mapToJson(styleSheet));
        }
    }
9054
@Override
	public void preparePaintComponent(final Request request) {
		if (!this.isInitialised() || resetButton.isPressed()) {
			String preferredState = request.getAppPreferenceParameter("example.preferred.state");
			stateSelector.setSelected(preferredState);
			this.setInitialised(true);
		}
	}
999237
private void addPostParams(final Request request) {
        if (assetVersions != null) {
            for (String prop : assetVersions) {
                request.addPostParam("AssetVersions", prop);
            }
        }

        if (functionVersions != null) {
            for (String prop : functionVersions) {
                request.addPostParam("FunctionVersions", prop);
            }
        }

        if (dependencies != null) {
            request.addPostParam("Dependencies", dependencies);
        }
    }
992893
@Override
	protected void preparePaintComponent(final Request request) {
		super.preparePaintComponent(request);
		WComponent content = getContent();

		if (content != null) {
			switch (getMode()) {
				case EAGER: {
					// Will always be visible
					content.setVisible(true);
					AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
					break;
				}
				case LAZY: {
					content.setVisible(isOpen());
					if (!isOpen()) {
						AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
					}

					break;
				}
				case DYNAMIC: {
					content.setVisible(isOpen());
					AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
					break;
				}
				case SERVER: {
					content.setVisible(isOpen());
					break;
				}
				case CLIENT: {
					// Will always be visible
					content.setVisible(true);
					break;
				}

				default:
					// do nothing.
					break;
			}
		}
	}
1298291
@Override
	protected void preparePaintComponent(final Request request) {
		if (!isInitialised()) {
			MyDataBean myBean = new MyDataBean();
			myBean.setName("My Bean");

			myBean.addBean(new SomeDataBean("blah", "more blah"));
			myBean.addBean(new SomeDataBean());

			repeaterFields.setData(myBean);

			setInitialised(true);
		}
	}