I have a page with a tabbedpanel with 2 item on on changing the selected item and reopening the page the last selected item is the selected tab. I want to set the first tab as the default tab how can i achieve this.
I have a JSFF page
<af:panelTabbed position="above" id="pt1" styleClass="AFStretchWidth" childCreation="lazy">
<af:showDetailItem id="tab1"
text="tab1"
disclosed="#{pageFlowScope.expandHeader}"
stretchChildren="first">
</af:showDetailItem>
<af:showDetailItem id="tab2"
text="tab2"
stretchChildren="first"
disclosed="#{pageFlowScope.expandLine}"
styleClass="AFStretchWidth">
</af:showDetailItem>
</af:panelTabbed>
And a Backing Bean How do i use these two so that when ever i open this page the first tab is opened by default.
Changing the disclosed only changes what tab opens the first time you open the page. If you reopen it after changing the tab the last opened tabbed is shown. Changing childCreation also didnot help.
I added a doneActionlistner
to the
<fnd:simplePanel
and a binding to the <af:panelTabbed
.
Now, from the bean i created a onDone action and also added a function to change the tab.
public void onDone(ActionEvent actionEvent) {
setTabActive(0);
return ;
}
public void setTabActive(int tab) {
FacesContext fc = FacesContext.getCurrentInstance();
ChangeManager cm = RequestContext.getCurrentInstance().getChangeManager();
ComponentChange ccTrue = new AttributeComponentChange("disclosed", Boolean.TRUE);
ComponentChange ccFalse = new AttributeComponentChange("disclosed", Boolean.FALSE);
if (this.myPanelTab != null) {
RichShowDetailItem activeTab = null;
RichShowDetailItem inActiveTab = null;
List<UIComponent> childUIComponent = this.myPanelTab.getComponent().getChildren();
if (childUIComponent != null && childUIComponent.size() > 0) {
for (int i = 0; i < childUIComponent.size(); i++) {
if (childUIComponent.get(i) instanceof RichShowDetailItem) {
if (i == tab) {
activeTab = (RichShowDetailItem)childUIComponent.get(i);
activeTab.setDisclosed(true);
cm.addComponentChange(fc, activeTab, ccTrue);
} else {
inActiveTab = (RichShowDetailItem)childUIComponent.get(i);
inActiveTab.setDisclosed(false);
cm.addComponentChange(fc, inActiveTab, ccFalse);
}
}
}
}
AdfFacesContext.getCurrentInstance().addPartialTarget(myPanelTab.getComponent());
}
}