一个页面包含rich face选项卡面板,并具有4个选项卡。在其中一个选项卡中,我有文本框和保存按钮。如果我移动到另一个选项卡,在不保存数据的情况下,它应该会显示弹出窗口,显示未保存的数据并阻止导航。
我尝试使用不同的java脚本调用一个弹出窗口,加载了rich:tabPanel的属性,但没有达到目的。
以下是代码
<rich:tabPanel onclick="#{rich:component('confirmation')}.show();return false" switchType="ajax" id="wizardTab" itemChangeListener="#{bean.tabChange}" activeItem="#{bean.activeTab}">
<rich:tab id="tab1"
// tab1
</rich:tab>
<rich:tab id="tab2"
</rich:tab>
<rich:tab id="tab3"
</rich:tab>
<rich:tab id="tab4"
<h:inputText id="test"
styleClass="span2" maxlength="25"
value="#{bean.rowForChange.code}">
<f:ajax event="blur" execute="@this"/>
</h:inputText>
<h:commandButton value="Update" styleClass="button"
style="width:160px"
action="#{bean.updtae}">
<a4j:ajax execute="paramValue"
render="table simeditPnl" />
</h:commandButton>
</rich:tab>
</rich:tabPanel>
<rich:popupPanel render="#{jCRDataRefreshManagement.updateStatus}" id="confirmation" modal="false" autosized="true" resizeable="false">
<f:facet name="header">Confirmation</f:facet>
<h:panelGrid>
<h:panelGrid columns="2">
<h:graphicImage value="/alert.png" />
<h:outputText value="You have unsaved changes. Are you sure?" style="FONT-SIZE: large;" />
</h:panelGrid>
<h:panelGroup>
<input type="button" value="OK"
onclick="#{rich:component('confirmation')}.hide();submit();return false" />
<input type="button" value="Cancel"
onclick="#{rich:component('confirmation')}.hide();return false" />
</h:panelGroup>
</h:panelGrid>
</rich:popupPanel>如果在选项卡4上的文本框中有任何未保存的数据,并尝试单击任何其他选项卡,则它应该停留在选项卡4中,并如上所述显示确认弹出框。
有了这个实现,每当我点击标签的时候,我的弹出窗口就会打开。
请指出我正在做的错误或给出上述场景的建议。任何已应用的帮助
发布于 2015-09-17 21:05:49
如果不想切换选项卡,请使用onbeforeitemchange并返回false,而不是单击。
如果您想延迟切换,请使用类似如下的命令:
saveTabs = function(event) {
oldItem = event.rf.data.oldItem,
newItem = event.rf.data.newItem;
}
<rich:tabPanel id="tabPanel" onbeforeitemchange="saveTabs(event); return false;" >当您决定切换使用时:
RichFaces.component("form:tabPanel").__itemsSwitcher().exec(oldItem, newItem);https://stackoverflow.com/questions/32621659
复制相似问题