0

我在 Datatable 中有一个 CommandButton 组件,它位于 TabView 组件中。CommandButton 组件的 ActionListener 方法不起作用。永远不会被解雇。

这是我的 XHTML 页面:

<p:dialog id="dlgView" widgetVar="wvDlgView"
    modal="true" closable="true" resizable="false">
    <p:outputPanel id="opViewUser">
    <h:form>
        <p:tabView id="tabViewUser">
            <p:tab title="DATOS PERSONALES">
                <p:dataTable id="dtUsuarios" rows="5" paginator="true"
                    selectionMode="single" selection="#{personController.system}">
                    ....
                    <p:column>

                        <p:commandButton value="Bloquear"  actionListener="#{personController.block}" />
                    </p:column>
                </p:dataTable>
            </p:tab>
        <p:tabView>
    </h:form>
    </p:outputPanel>
</p:dialog>

提前致谢 :)

PD:PF 3.5,JSF (Mojarra) 2.1.3,Tomcat:6.0.10

4

1 回答 1

1

很抱歉没有发布完整的代码并稍后回答。无论如何,我认为已经没有必要了,因为我解决了我的问题。更详细地解释问题:

我在选项卡组件上有一个与此类似的结构:

<p:tab>
<h:form id="formTab" prependId="false">
    <h:panelGrid columns="3">
        <p:outputLabel value="Sistema " for="sltSystem"/>
        <p:selectOneMenu id="sltSistema" required="true"
            value="#{personController.idSistema}" >
            <f:selectItems value="#{personController.listSistemas" 
                var="s" itemLabel="#{s.valor}" itemValue="#{s.id}"/>
        </p:selectOneMenu>

        <p:outputLabel value="Rol " for="sltRol"/>
        <p:selectOneMenu id="sltRol" required="true" 
            value="#{personController.idRol}" >
            <f:selectItems value="#{personController.listRoles}" 
                var="r" itemLabel="#{r.valor}" itemValue="#{r.id}"/>
        </p:selectOneMenu>
    </h:panelGrid>


    <p:dataTable id="dtUsersSystems" rows="5" paginator="true"
        value="#{personController.userSystems}" var="s" rowKey="#{s.id}" >

        <p:column headerText="SISTEMA">
            <h:outputText value="#{s.sistema}" />
        </p:column>

        <p:column headerText="ROL">
            <h:outputText value="#{s.rol}" />
        </p:column>

        <p:column headerText="ESTADO">
            <h:outputText value="#{s.estado}"/>
        </p:column>

        <p:column>

            <p:commandButton value="Bloquear" icon="ui-icon-cancel" actionListener="#{personController.blocked}"></p:commandButton>
        </p:column>
    </p:dataTable>
<h:form>
</p:tab>

As you can see sltSystem and sltRol components have required attribute in true. For that when I clicked on button "Bloquear" its ActionListener method not was invoked because after I should select a value on sltSystem and sltRol components.

Therefore new page structure is this:

<p:tab>
<h:form id="formSelect" prependId="false">
    <h:panelGrid columns="3">
        <p:outputLabel value="Sistema " for="sltSystem"/>
        <p:selectOneMenu id="sltSistema" required="true"
            value="#{personController.idSistema}" >
            <f:selectItems value="#{personController.listSistemas" 
                var="s" itemLabel="#{s.valor}" itemValue="#{s.id}"/>
        </p:selectOneMenu>

        <p:outputLabel value="Rol " for="sltRol"/>
        <p:selectOneMenu id="sltRol" required="true" 
            value="#{personController.idRol}" >
            <f:selectItems value="#{personController.listRoles}" 
                var="r" itemLabel="#{r.valor}" itemValue="#{r.id}"/>
        </p:selectOneMenu>
    </h:panelGrid>
</h:form>
<h:form id="formDataTable" prependId="false">
    <p:dataTable id="dtUsersSystems" rows="5" paginator="true"
        value="#{personController.userSystems}" var="s" rowKey="#{s.id}" >

        <p:column headerText="SISTEMA">
            <h:outputText value="#{s.sistema}" />
        </p:column>

        <p:column headerText="ROL">
            <h:outputText value="#{s.rol}" />
        </p:column>

        <p:column headerText="ESTADO">
            <p:graphicImage value="#{s.estado}"/>
        </p:column>

        <p:column>

            <p:commandButton value="Bloquear" icon="ui-icon-cancel" actionListener="#{personController.blocked}"></p:commandButton>
        </p:column>
    </p:dataTable>
<h:form>
</p:tab>

A form for selectonemenu components and other form for datatable component.

Thanks to all :)

于 2013-06-05T21:00:22.950 回答