0

在我的网络应用程序中,我有以下数据表:

<!-- Exibição da lista de públicos -->
                <p:dataTable id="dtEventos" 
                             value="#{relatoriosBean.listaEventos}"
                             paginator="true" rows="5" 
                             rowsPerPageTemplate="5,10"
                             paginatorPosition="bottom"
                             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             var="atual"
                             emptyMessage="Não há eventos para exibição"
                             rendered="#{relatoriosBean.exibirPainelDados}">

                    <f:facet name="header">
                        Eventos
                    </f:facet>

                    <p:column sortBy="#{atual.nmeEvento}" styleClass="wrap">
                        <f:facet name="header">
                            Nome
                        </f:facet>
                        <p:panelGrid columns="1" 
                                     styleClass="gridNoLine">
                            <h:outputLabel id="olViewNomeEvento" 
                                           value="#{atual.nmeEvento}" 
                                           styleClass="t2"/>
                            <p:separator title="Descrição do evento"/>
                            <p:row>
                                <h:outputLabel value="Início: " styleClass="t2"/>
                                <h:outputLabel value="#{atual.dtaInicioEvento}"/>
                                <h:outputLabel value="Término: " styleClass="t2"/>
                                <h:outputLabel value="#{atual.dtaTerminoEvento}"/>
                            </p:row>
                            <h:outputLabel value="#{atual.dscEvento}" 
                                           styleClass="wrap"/>
                        </p:panelGrid>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            Relatórios
                        </f:facet>
                        <p:panelGrid columns="2" styleClass="gridNoLine">
                            <p:selectOneMenu value="#{relatoriosBean.tipoEventoRelatorioSelecionado}"
                                             required="true"
                                             requiredMessage="Selecione o relatório a ser gerado."
                                             effect="fade">
                                <f:selectItem itemLabel="Selecione um item..." itemValue=""/>
                                <f:selectItems value="#{relatoriosBean.tiposEventoRelatorios}">
                                </f:selectItems>
                            </p:selectOneMenu>
                            <p:commandButton icon="ui-icon-document" 
                                             title="Gerar relatório"
                                             actionListener="#{relatoriosBean.gerarRelatorio}"
                                             update="UPDATE THE SELECTONEMENU OF THE LINE">
                                <f:setPropertyActionListener value="#{atual.idtEvento}"
                                                             target="#{relatoriosBean.idEventoSelecionado}}"/>
                            </p:commandButton>
                        </p:panelGrid>
                    </p:column>
                </p:dataTable>

如您所见,在其中一个数据表列中,我有一个 selectOneMenu。在同一列中,我有一个设置了 actionListener 的按钮。好吧,我想要的是:根据命令按钮的单击更新列的 selectOneMenu。有办法做到这一点吗?

好的!现在 f:setPropertyActionListener 没有设置属性 eventtoSelecionado。这是代码:

<p:dataTable value="#{relatoriosBean.listaEventos}"
                             var="atual">
                    ...

                    <p:column>
                        <f:facet name="header">
                            Relatórios
                        </f:facet>
                        <p:panelGrid columns="2" 
                                     styleClass="gridNoLine">
                            <p:selectOneMenu id="somRelatorios"
                                             value="#{relatoriosBean.relatorioSelecionado}"
                                             required="true"
                                             requiredMessage="Selecione o relatório a ser gerado."
                                             effect="fade">
                                <f:selectItem itemLabel="Selecione um item..." itemValue=""/>
                                <f:selectItems value="#{relatoriosBean.relatorios}">
                                </f:selectItems>
                            </p:selectOneMenu>
                            <p:commandButton id="cbGerarRelatorio"
                                             icon="ui-icon-document" 
                                             title="Gerar relatório"
                                             actionListener="#{relatoriosBean.gerarRelatorio}"
                                             update=":frmRelatorios:opPainelDados"
                                             process="@this somRelatorios"
                                             immediate="true">
                                <f:setPropertyActionListener target="#{relatoriosBean.eventoSelecionado}"
                                                             value="#{atual}"/>
                            </p:commandButton>
                        </p:panelGrid>
                    </p:column>
                </p:dataTable>

在 gerarRelatorio 动作侦听器中,属性 eventtoSelecionado 为 null。怎么了?

4

1 回答 1

1

当然,将此添加id=mySelectOne到您<p:selectOneMenu/><p:commandButton/>设置中,并将update属性设置为update="mySelectOne". @ViewScoped但是为了在这个 ajax 更新中获得最好的结果,如果你还没有这样做的话,我强烈建议你设置你的托管 bean 注释。您的命令按钮在更新结束时应如下所示

     <p:commandButton icon="ui-icon-document" 
                                         title="Gerar relatório"
                                         actionListener="#{relatoriosBean.gerarRelatorio}"
                                         update="mySelectOne">
于 2012-10-10T00:35:27.570 回答