我有一个带有选项卡面板的页面,其中有 2 个项目用于更改所选项目并重新打开页面,最后一个所选项目是所选选项卡。我想将第一个选项卡设置为默认选项卡,如何实现此目的。
我有一个 JSFF 页面
<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>
还有一个支持豆 我如何使用这两个,以便当我打开此页面时默认打开第一个选项卡。
要公开 panelTabbed 的第二个 showDetailItem,您需要将其公开属性设置为 true,并将另一个 showDetailItem 公开属性设置为 false。
在您的情况下,布尔值#{pageFlowScope.expandLine}需要等于TRUE,#{pageFlowScope.expandHeader}等于FALSE
您只需将值 true 或 false 放入 dislosed 属性中即可对其进行测试。 例如,这会起作用:
<af:panelTabbed position="above" id="pt1" styleClass="AFStretchWidth" childCreation="lazy">
<af:showDetailItem id="tab1"
text="tab1"
disclosed="false"
stretchChildren="first">
</af:showDetailItem>
<af:showDetailItem id="tab2"
text="tab2"
stretchChildren="first"
disclosed="true"
styleClass="AFStretchWidth">
</af:showDetailItem>
</af:panelTabbed>
或没有公开=“假”的事件,因为公开的默认值为假:
<af:panelTabbed position="above" id="pt1" styleClass="AFStretchWidth" childCreation="lazy">
<af:showDetailItem id="tab1"
text="tab1"
stretchChildren="first">
</af:showDetailItem>
<af:showDetailItem id="tab2"
text="tab2"
stretchChildren="first"
disclosed="true"
styleClass="AFStretchWidth">
</af:showDetailItem>
</af:panelTabbed>
在这两个示例中,第二个 showDetailItem 将在首次显示时公开。
更改公开内容只会更改您第一次打开页面时打开的选项卡。如果您在更改选项卡后重新打开它,则会显示上次打开的选项卡。改变 childCreation 也没有帮助。
我在其中添加了
doneActionlistner
<fnd:simplePanel
以及与 <af:panelTabbed
的绑定。
现在,我从 bean 创建了一个 onDone 操作,并添加了一个更改选项卡的函数。
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());
}
}