开发者

Data table headers alone coming if there is no values to load

开发者_JAVA百科if there is no data to display, jsf data table shows headers only. How to say that no records available and also tell me is there any way to get the row index with out having a specific method. thanks in advance

. .


You can make use of the rendered attribute of the component in question to set whether to render it in the component tree or not. E.g.

<h:dataTable value="#{bean.data}" rendered="#{not empty bean.data}">
    ...
</h:dataTable>
<h:outputText value="Data is empty!" rendered="#{empty bean.data}" />

As you see, it can take a boolean expression, so any of the following boolean expression examples are valid:

<h:someComponent rendered="#{bean.booleanValue}" />
<h:someComponent rendered="#{bean.intValue > 10}" />
<h:someComponent rendered="#{bean.objectValue == null}" />
<h:someComponent rendered="#{bean.stringValue != 'someValue'}" />
<h:someComponent rendered="#{!empty bean.collectionValue}" />
<h:someComponent rendered="#{!bean.booleanValue && bean.intValue != 0}" />
<h:someComponent rendered="#{bean.stringValue == 'oneValue' || bean.stringValue == 'anotherValue'}" />

The not is by the way an alias for !. More about available EL operators can be found here.

To have a rowindex, make use of UIData#getRowIndex():

<h:dataTable binding="#{table}">
    <h:column><h:outputText value="#{table.rowIndex + 1}" /></h:column>
</h:dataTable>


    <h:column>
        <f:facet name="header">
            <h:outputText value="S.No"></h:outputText>
        </f:facet>
        <h:outputText value="#{row+1}"></h:outputText>
    </h:column>
     .
     .

i achieved it with using tomhawk

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜