PrimeFaces DataTable选项在dialog.show()上为空 [英] PrimeFaces DataTable selection goes null on dialog.show()

查看:112
本文介绍了PrimeFaces DataTable选项在dialog.show()上为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要点击一个datatable的行,并显示一个从datatable的所选项目中加载数据的对话框



选择一切正常,但是一旦显示对话框,所选元素就会设置为null:/



以下是一些代码:

 < h:form id =form> 
< pou:dataTable widgetVar =convid =mexvar =convvalue =#{messagesBean.listaConversazioni}paginator =truerowKey =#{conv}paginatorPosition = bottom
selection =#{messagesBean.destinatario}selectionMode =singlerows =15>
< pou:ajax event =rowSelect
oncomplete =convDialog.show()update =:form:display,:growl,,menuPanel/>
< pou:column>
< f:facet name =header>
< h:outputText value =Conversazioni/>
< / f:facet>
< h:outputText value =#{conv.username}/>
< / pou:column>
< / pou:dataTable>

< pou:dialog id =convDialogheader =ConversazionewidgetVar =convDialogonHide =conv.unselectAllRows()position =centermodal =trueresizable = falsedraggable =false
showEffect =explodehideEffect =explodeheight =635width =620>
< h:panelGrid id =display>
< pou:panel id =postForm>
< div align =center>
< pou:inputTextarea value =#{messagesBean.messaggio}cols =50autoResize =truemaxlength =255/> < br />
< pou:commandButton action =#{messagesBean.invia(messagesBean.destinatario)}value =Inviaupdate =display,,growl/>
< / div>
< / pou:panel>
< pou:panel>
< div class =conversazionePanel>
< pou:dataTable id =mexTablevar =mexvalue =#{messagesBean.caricaConversazione(messagesBean.destinatario)}rowStyleClass =postTable>
< pou:column style =border:none; background:rgba(0,0,0,0)>
< div id =messaggio _#{mex.idMessaggio}>
< pou:outputPanel rendered =#{mex.mittente eq loginBean.utente}>
< pou:panelGrid columns =2>
< h:outputText value =Io/>
< div class =messaggioInviato>#{mex.testo}< / div>
< / pou:panelGrid>
< / pou:outputPanel>
< pou:outputPanel rendered =#{mex.destinatario eq loginBean.utente}>
< pou:panelGrid columns =2>
< div class =messaggioRicevuto>#{mex.testo}< / div>
< h:outputText value =#{mex.mittente.username}/>
< / pou:panelGrid>
< / pou:outputPanel>
< / div>
< / pou:column>
< / pou:dataTable>
< / div>
< / pou:panel>
< / h:panelGrid>
< / pou:dialog>
< / h:form>

_



#{messagesBean.listaConversazioni} 返回用户列表



_



#{conv} 是用户



_



#{messagesBean.destinatario} 是我需要设置的用户。奇怪的是,这个奇怪的想法是:



pre> < pou:dataTable id =mexTablevar =mexvalue =#{messagesBean.caricaConversazione(messagesBean.destinatario)}

而在同一个对话框中

  < h:outputText value =#{messagesBean.destinatario == null}> 

打印true:\



什么是错了吗?

解决方案

不确定,但 rowKey =#{conv.id}也许?


I've got a BIG problem using Datatable and Dialog together.

I need to click on a datatable's row and showing a dialog which loads data from datatable's selected item.

Selection goes fine, but the selected element is set to null as soon as the dialog is shown :/

Here's some code :

<h:form id="form">  
                    <pou:dataTable widgetVar="conv" id="mex" var="conv" value="#{messagesBean.listaConversazioni}" paginator="true" rowKey="#{conv}" paginatorPosition="bottom"  
                                   selection="#{messagesBean.destinatario}"  selectionMode="single" rows="15">  
                        <pou:ajax event="rowSelect" 
                                  oncomplete="convDialog.show()" update=":form:display, :growl, :menuPanel" />  
                        <pou:column>
                            <f:facet name="header">
                                <h:outputText value="Conversazioni"/>                                                                        
                            </f:facet>
                            <h:outputText value="#{conv.username}"/>                                
                        </pou:column>  
                    </pou:dataTable>                     

                    <pou:dialog id="convDialog" header="Conversazione" widgetVar="convDialog" onHide="conv.unselectAllRows()" position="center" modal="true" resizable="false" draggable="false"  
                                showEffect="explode" hideEffect="explode" height="635" width="620">                                  
                        <h:panelGrid id="display">
                            <pou:panel id="postForm">
                                <div align="center">
                                    <pou:inputTextarea value="#{messagesBean.messaggio}" cols="50" autoResize="true" maxlength="255"/> <br/>
                                    <pou:commandButton  action="#{messagesBean.invia(messagesBean.destinatario)}" value="Invia" update="display, :growl"/>
                                </div>   
                            </pou:panel>             
                            <pou:panel>
                                <div class="conversazionePanel">
                                    <pou:dataTable id="mexTable" var="mex" value="#{messagesBean.caricaConversazione(messagesBean.destinatario)}" rowStyleClass="postTable">                                         
                                        <pou:column style="border: none; background: rgba(0,0,0,0)">  
                                            <div id="messaggio_#{mex.idMessaggio}">
                                                <pou:outputPanel rendered="#{mex.mittente eq loginBean.utente}">
                                                    <pou:panelGrid columns="2">
                                                        <h:outputText value="Io"/>
                                                        <div class="messaggioInviato">#{mex.testo}</div>
                                                    </pou:panelGrid> 
                                                </pou:outputPanel> 
                                                <pou:outputPanel rendered="#{mex.destinatario eq loginBean.utente}">                                                                                                                                                
                                                    <pou:panelGrid columns="2">
                                                        <div class="messaggioRicevuto">#{mex.testo}</div>
                                                        <h:outputText value="#{mex.mittente.username}"/>
                                                    </pou:panelGrid>                                                                                                
                                                </pou:outputPanel>                                                 
                                            </div>
                                        </pou:column>                                        
                                    </pou:dataTable>   
                                </div>
                            </pou:panel>                            
                        </h:panelGrid>                                                                                    
                    </pou:dialog>                        
                </h:form>

_

#{messagesBean.listaConversazioni} returns a List of User

_

#{conv} is a User

_

#{messagesBean.destinatario} is the User that I need to set. It takes conv's value when I click on the row, but it suddenly takes null.

The strange think is that

<pou:dataTable id="mexTable" var="mex" value="#{messagesBean.caricaConversazione(messagesBean.destinatario)}"

while, in the same dialog

<h:outputText value="#{messagesBean.destinatario==null}">

prints true :\

What's wrong with it ?

解决方案

Not sure, but rowKey="#{conv.id}" maybe?

这篇关于PrimeFaces DataTable选项在dialog.show()上为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆