【问题标题】:Primefaces, activeindex actionlistener not calling in multiple tabsPrimefaces,activeindex actionlistener没有在多个选项卡中调用
【发布时间】:2012-03-25 21:37:50
【问题描述】:

您好,我使用的是 primefaces 3.2 版 我正在使用的 ui 布局是 tabview,在它里面,我有手风琴面板,在手风琴的每个标签里面,我有两种形式。

就像

tabview>tab>accordionpanel>tab>form1 和

tabview>tab>accordionpanel>tab>form2 等等...

现在,问题是在上述场景中没有调用活动索引操作。但是,当我从手风琴面板选项卡中删除一个 froms 时,它会被调用并且工作正常。


这是我的 xhtml tabview 代码

        <p:tabView id="tabView" activeIndex="#{profileInfoManagedBean.myCurrentTab}" >
            <p:ajax event="tabChange" listener="#{profileInfoManagedBean.tabIsChanged}" />

            <p:tab id="locationInfoTab" title="Location Info">

                <p:accordionPanel id="aPanel">

                    <p:tab id="tab1" title="Country">
                        <h:form id="form1">
                            <p:growl id="growl" life="5000" />

                            <p:messages id="messages"  /> 

                            <h:panelGrid columns="3" cellpadding="5" cellspacing="5">

                                <p:column>
                                    <h:outputLabel for="country"  value="Country: "></h:outputLabel>
                                </p:column>
                                <p:column>
                                    <p:inputText id="country" value="#{profileInfoManagedBean.country.country}" required="true" label="City">

                                        <f:validateLength minimum="5" maximum="20" />
                                        <p:ajax event="blur" update="msg1"></p:ajax>
                                    </p:inputText>
                                </p:column>
                                <p:column>
                                    <p:message id="msg1" for="country" display="icon"></p:message>
                                </p:column>

                            </h:panelGrid>
                            <p:commandButton type="submit" action="#{profileInfoManagedBean.addCountry}" value="Save" ajax="true" ></p:commandButton>

                        </h:form>
                        <p:separator />

                        <h:form id="countryDataTableForm">
                            <p:panel>
                                <p:growl id="messagesww" />
                                <p:confirmDialog id="confirmDialog" message="Are you sure you want to delete the selected row ?"
                                                 header="Deleting Row" severity="alert" widgetVar="confirmation1">
                                    <p:commandButton id="confirm" value="Yes Sure" update="messagesww" oncomplete="confirmation1.hide()"
                                                     action="#{profileInfoManagedBean.deleteObject}" />
                                    <p:commandButton id="decline" value="Not Yet" onclick="confirmation1.hide()" type="button" />
                                </p:confirmDialog>

                                <p:dataTable style="width: 700px;" var="coun" value="#{profileInfoManagedBean.countryList}" selection="#{profileInfoManagedBean.deletingObj}" rowKey="#{coun.countryId}"
                                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                             paginator="true" rows="5" rowsPerPageTemplate="10,15,20,25" editable="true">
                                    <p:ajax event="rowEdit" update="@this"
                                            listener="#{profileInfoManagedBean.onEditRow}" />


                                    <p:column headerText="Country">
                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{coun.country}" />
                                            </f:facet>
                                            <f:facet name="input">
                                                <p:inputText value="#{coun.country}" style="width:100%" />
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column id="inactive" filterBy="#{coun.isActive}"   
                                              headerText="isActive" footerText="exact" 
                                              filterOptions="#{profileInfoManagedBean.isActiveDropDown}"
                                              filterMatchMode="exact">

                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{coun.isActive}"></h:outputText>
                                            </f:facet>
                                            <f:facet name="input">
                                                <h:selectOneMenu value="#{coun.isActive}" >  
                                                    <f:selectItem itemLabel="True" itemValue="true" />  
                                                    <f:selectItem itemLabel="False" itemValue="false" /> 
                                                </h:selectOneMenu> 
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column headerText="Edit">
                                        <p:rowEditor />
                                    </p:column>

                                    <p:column headerText="Delete">

                                        <p:commandButton type="button" onclick="confirmation1.show()" 
                                                         id="delCountry" title="Delete Country" icon="ui-icon ui-icon-trash" />
                                    </p:column>

                                    <p:column selectionMode="single">
                                        <f:facet name="header">
                                            <h:outputText value="select" />
                                        </f:facet>
                                    </p:column>


                                </p:dataTable>
                            </p:panel>

                        </h:form>
                    </p:tab>

                </p:accordionPanel>

            </p:tab>

            <p:tab id="basicInfoTab" title="Basic Info">
                <p:accordionPanel id="aPanel2">
                    <p:tab id="tab2" title="basic   info">
                        <h:form id="dkk">
                            This is basic info tab.
                        </h:form>
                        <h:form id="ddkk">
                            This is basic info tab.
                        </h:form>
                    </p:tab>
                </p:accordionPanel>
            </p:tab>

        </p:tabView>   




 I've got multiple tabs in the tabview and also multiple tabs in each accordion panel.

    Waiting for the response.

【问题讨论】:

    标签: java jsf primefaces


    【解决方案1】:

    使用

    <p:tab  id="tab1" title="Quick Search"> 
    <p:commandButton   process="tab1"  value="Search"  
     actionListener="#{TTCPage.searchTrackTime}"  id="searchval" update="track"/> 
    

    【讨论】:

    • 我在这里使用活动索引,每当单击选项卡时,它都会存储在绑定的 bean 成员变量中。在您的建议中,我必须按命令按钮而不是选项卡来执行此操作。如果你不想说我从你的代码中得到了什么,请解释一下。谢谢
    【解决方案2】:

    您的 bean 在视图范围内吗?如果在 myCurrentTab 的 getter 中设置断点,它会在调试模式下停止吗?

    【讨论】:

    • 我的 bean 是会话范围的。在调试模式下,当我跳过“return myCurrrentTab”语句时,它会转到 Method.java 类的调用方法的返回语句。但它不会停止调试器。
    • 你真的需要accordionPanel 面板吗?,我总是遇到标签内复杂组件的问题。也许你可以问primefaces。或者您可以使用其他组件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-10
    • 1970-01-01
    • 2012-05-15
    • 1970-01-01
    • 1970-01-01
    • 2013-12-19
    相关资源
    最近更新 更多