0

I've get the following code:

<p:dataTable var="message"
                id="messages"
                emptyMessage="No messages"
            paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} 
                {CurrentPageReport} {NextPageLink} {LastPageLink}"
                value="#{messagesManagedBean.dataModel}" 
            paginator="true" 
            rowsPerPageTemplate="10,20,30" 
            rows="10"
            lazy="true">
            <p:column width="30%"
                      sortBy="#{message.msgTime}" 
                      filterBy="#{message.text}" 
                      >
                <p:panel id="messageid" 
                     header="#{message.sender.nickname}:#{message.msgTime}"
                     style="color: ;text-align: left; background-color: #{message.sender.userId eq messagesManagedBean.currentUser.userId ? '#B7FFFF' : '#C5FFD4'}">
                     <f:facet name="actions">
                        <p:commandLink
                            styleClass="ui-panel-titlebar-icon ui-corner-all 
                            ui-state-default ui-icon ui-icon-close"
                            action="#{messagesManagedBean.deleteMessage(message.msgId)}"
                            update=":table">
                        </p:commandLink>
                    </f:facet>
                    <p:graphicImage value="#{message.sender.avatarUrl}" width="100" height="100"/>
                    <h:outputText value="#{message.text}" />
                </p:panel>
            </p:column>
    </p:dataTable>

There is a screenshot: enter image description here

Obviously, when I'm clicking on the cross, the message should be deleted by {messagesManagedBean.deleteMessage(message.msgId)} method. The problem is that at the first time, message==null. When I'm clicking on the cross at the second time, deleteMessage method isn't invoked at all!! At the third time, everything is all right and I get correct message object.

How can I "initialize" message variable in advance?

  • Try setting the `process` attribute of that `` to `@this` (``). – Tiny Feb 05 '15 at 20:48
  • Does that link work only when you click **the same** link thrice? – Tiny Feb 05 '15 at 21:02
  • what if you change the action of the commandLink to an actionListener? And why do you need to update the table at that time? Does't the panel close? by itself? – Kukeltje Feb 05 '15 at 21:07
  • @Tiny No, for example, I can click on another message twice. It begans to work after some action with the form. For example, after typing something on **another** form... – Arseny Istlentyev Feb 05 '15 at 21:13
  • @Kukeltje I've changed an action to an actionListener. Now, it works after two clicks. (At the first time the message object is null, at the second - all right). As far as I understand, the panel shouldn't close without an update attribute. – Arseny Istlentyev Feb 05 '15 at 21:22
  • The panel in the PF showcase does this (afaics) please create a full but minimal example see [ask] maybe you have nested forms – Kukeltje Feb 05 '15 at 22:01

0 Answers0