Custom UIShell: making closeable the initial tabs.

With this pattern, among many other features, we have an option that allows us to open initial tabs. (when the application is started).–>closeable true in adfc-config

The problem is that if we make closeable this initial tab, when we close the initial tab and we try to open the initial tab again. We get a NullPointerException in addTab method of DynTabManager class

The problem is that the TaskflowId property in getInstance method  of  DynTab class is null.

I added these lines and now the initial Tab can be closeable.

public static DynTab getInstance(String tabName) {
 String beanName = tabName + "DynTab";
 String expr = "#{" + beanName + "}";
 DynTab tab = (DynTab)JsfUtils.getExpressionValue(expr);
 if (tab == null) {
  // try viewScope, must be used when tab is initially displayed
  expr = "#{viewScope." + beanName + "}";
  tab = (DynTab)JsfUtils.getExpressionValue(expr);
 }
 if (tab == null) {
  sLog.severe("Could not find DynTab bean " + beanName + "!");
 }
 tab.setName(tabName);

 //workaround to re-open the initial Tabs
 if ((tab.getTitle() == null) || (tab.getTitle().length() == 0)) {
  tab.setTitle(tabName);
 }
 tab.setTaskflowId(TaskFlowId.parse(tab.getTaskFlowIdString()));

 return tab;
}

and add a if in addTab method of DynTabManager class

public void addTab(DynTab tabToAdd) {
      if (tabTracker.getNumActive() >= tabTracker.getMaxNumberOfTabs()) {
            handleTooManyTabsOpen();
      } else {
          // The list of tabs doesn't get fragmented, so the first inactive tab always
          // shows as the right most tab.
          DynTab tab = getFirstInactiveTabOrThrow();
          tab.setTitle(tabToAdd.getTitle());
          tab.setActive(true);
          tab.setTaskflowId(tabToAdd.getTaskflowId());
          tab.setUniqueIdentifier(tabToAdd.getUniqueIdentifier());
          tab.setParameters(tabToAdd.getParameters());
          // add the DynTabManager instance as taskflow parameter so the
          // taskflow itself can open new tabs, and close tabs.
          if (tab.getParameters() != null) {
               tab.getParameters().put("dynTabManager", this);
               // add tab id so the taskflow iktself can change its label
               tab.getParameters().put("dynTabId", tab.getId());
           }
           tabTracker.setNumActive(tabTracker.getNumActive() + 1);
           setSelectedTabId(tab.getId());
        }
    }

Note:This post does not talk about Oracle UI Shell, we are talking about the UI Shell that can be downloaded from here.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s