Ejemplo n.º 1
0
  /**
   * This method has been overridden to load a WComponent from parameters.
   *
   * @param httpServletRequest the servlet request being handled.
   * @return the top-level WComponent for this servlet.
   */
  @Override
  public synchronized WComponent getUI(final Object httpServletRequest) {
    String configuredUIClassName = Config.getInstance().getString(COMPONENT_TO_LAUNCH_PARAM_KEY);

    if (sharedUI == null || !Util.equals(configuredUIClassName, uiClassName)) {
      uiClassName = configuredUIClassName;
      WComponent ui = createUI();

      if (ui instanceof WApplication) {
        sharedUI = (WApplication) ui;
      } else {
        LOG.warn(
            "Top-level component should be a WApplication." + " Creating WApplication wrapper...");

        sharedUI = new WApplication();
        ui.setLocked(false);
        sharedUI.add(ui);
        sharedUI.setLocked(true);
      }

      if (Config.getInstance().getBoolean(SHOW_MEMORY_PROFILE_PARAM_KEY, false)) {
        ProfileContainer profiler = new ProfileContainer();

        sharedUI.setLocked(false);
        sharedUI.add(profiler);
        sharedUI.setLocked(true);
      }
    }

    return sharedUI;
  }
    @Override
    protected void preparePaintComponent(final Request request) {
      super.preparePaintComponent(request);

      if (!isInitialised()) {
        beanContainer.setBean(new SimpleFormBean());
        setInitialised(true);
      }
    }