DataTable: Show Row When Provided With An Empty List

Hi all,

I've just started looking at JSF and to start I'm trying to throw together a little webmail application. At the moment I have the below simple DataTable. All works fine but I am wondering about one thing. When the user has no emails in their inbox, instead of just showing an empty table I would like to have a row that spans the total number of columns alerting the user that they have no email.Can anyone suggest an easy way to do this?

I can see that MyFaces' DataTable has a "renderIfBlank" attribute which I could use to hide the table and then create create a new blank table but this will mean duplicating a chunk of code.

So here's my code. As I touched on earlier - I'm using MyFaces so that's where the tags with a t prefix are from.

<t:dataTable id="yourmessages" rows="20"

var="message" value="#{userBean.folder.messages}"

rowIndexVar="rowIndex" width="700px">

<t:column width="30%">

<f:facet name="header">

<f:verbatim>

From

</f:verbatim>

</f:facet>

<t:outputText value="#{message.from}" />

</t:column>

<t:column width="40%">

<f:facet name="header">

<f:verbatim>

Subject

</f:verbatim>

</f:facet>

<t:outputText value="#{message.subject}" />

</t:column>

<t:column width="15%">

<f:facet name="header">

<f:verbatim>

Date

</f:verbatim>

</f:facet>

<t:outputText value="#{message.sentDate}" />

</t:column>

<t:column width="15%">

<f:facet name="header">

<f:verbatim>

Size

</f:verbatim>

</f:facet>

<t:outputText value="#{message.size}" />

</t:column>

</t:dataTable>

[2362 byte] By [LTheobalda] at [2007-11-27 6:00:53]
# 1
You can't do. But I don't see duplicating if you do it as follows:<h:dataTable rendered="#{!empty myBean.dataList}" /><h:outputText rendered="#{empty myBean.dataList}" value="No data!"
BalusCa at 2007-7-12 16:39:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...