Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabView shows content of all tabs if all tabs are dynamic #1186

Closed
de-graeuler opened this issue Jan 25, 2022 · 2 comments
Closed

TabView shows content of all tabs if all tabs are dynamic #1186

de-graeuler opened this issue Jan 25, 2022 · 2 comments
Labels

Comments

@de-graeuler
Copy link

Starting with version 1.4.2, tabview initially shows the content of all tabs, if all tabs are created dynamically. This is caused the "active" style being set for all of them:
grafik
I discovered this in 1.5.0. Using 1.4.1 it works.
The issue reproducible with these files:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:b="http://bootsfaces.net/ui"
	xmlns:h="http://java.sun.com/jsf/html">
<h:head />
<h:body>
  <b:container>
    <b:column>
      <b:tabView>
<!-- 
        <b:tab title="Static Tab">Static Tab</b:tab>
 -->
        <b:tab title="#{tab.title}"  value="#{tabView.tabs}" var="tab">
          #{tab.text}
        </b:tab>
      </b:tabView>
    </b:column>
  </b:container>
</h:body>
</html>

As soon as the static tab is not commented, the tab view works as expected.

Tab and tabView are just very simple pojos, where TabViewBean builds a tabs List adding TabBeans constructed with title and string parameter.

TabViewBean:

package tabview;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;

@ManagedBean(name = "tabView")
public class TabViewBean {

  List<TabBean> _tabs = new ArrayList<>();

  @PostConstruct
  public void createTabs() {
    _tabs.add(new TabBean("Dynamic Tab 1", "Content 1"));
    _tabs.add(new TabBean("Dynamic Tab 2", "Content 2"));
    _tabs.add(new TabBean("Dynamic Tab 3", "Content 3"));
  }
	
  public List<TabBean> getTabs() {
    return _tabs;
  }
}

TabBean:

package tabview;

import javax.faces.bean.ManagedBean;

@ManagedBean(name="tab")
public class TabBean {

  private String _title;
  private String _text;

  public TabBean(String title, String text) {
    _title = title;
    _text = text;
  }

  public String getTitle() {
    return _title;
  }

  public String getText() {
    return _text;
  }
}
@de-graeuler
Copy link
Author

I dug into the history of Tab rendering a little bit, and I think i found the cause for the issue: Since ccabe13, integrated as a bugfix for issue #1054, the offset value is not incremented within the runnable.

TabViewRenderer

private static void encodeTabContentPanes(FacesContext, ResponseWriter, TabView, int, List<UIComponent>)
[...]
     Runnable r = new Runnable() {
      public void run() {
       try {
        encodeTabPane(context, writer, tab,
          (currentIndex+currentOffset == currentlyActiveIndex) && (!tabView.isDisabled()));
       } catch (IOException ex) {
        // exotic case, suffice it to log it
        LOGGER.log(Level.SEVERE, "An exception occurred while rendering a tab.", ex);
       }
      }
     };

So if the view's first tab is a TabRepeat instance, all contained tabs are rendered with the same isActive state.

@stephanrauh
Copy link
Collaborator

I'm afraid development of BootsFaces has slowed down considerably. We'll never manage to address this issue. Let's close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants