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:
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?