开发者

No data found message inside h:dataTable or rich:dataTable?

开发者 https://www.devze.com 2023-01-27 08:27 出处:网络
How do i display a \'No开发者_如何学JAVA Data Found\' message inside a h:dataTable or a rich:dataTable. The header of the table should show the fields say Name, Roll Number and Class; The UI should sh

How do i display a 'No开发者_如何学JAVA Data Found' message inside a h:dataTable or a rich:dataTable. The header of the table should show the fields say Name, Roll Number and Class; The UI should show the header and a no data found message in the data section of the h:dataTable

Thanks.


Just a suggestion to make it easier to make the empty-message a part of the table, if you are not using the table footer anyway:

 ...
 </h:column>
 <f:facet name="footer">
    <h:outputText value="Table is empty" styleClass="someStyleClass" rendered="#{empty bean.list}" />
 </f:facet> 
 </h:datatable>

Some styling might be necessary anyway, but in my opinion it looks better in your source code.


That's not possible with h:dataTable or rich:dataTable. The PrimeFaces p:dataTable has an emptyMessage attribute which does exactly that.

Your best bet is to put a message below the table which is rendered when the table is empty. You could use CSS to give it the same style as the table so that it look like part of the table.

<h:dataTable value="#{bean.list}">
    ...
</h:dataTable>
<h:outputText value="Table is empty" rendered="#{empty bean.list}">


Completely Possible.

function myFunc(){
  $('#bodyForm\\:assetTrackingTravellingTable').grDataTable({
  sDom : 'zrtp'
 });
  
  }
   
<script type="text/javascript"
		src="#{facesContext.externalContext.requestContextPath}/member/assets/js/jquery.dataTables.js"></script>	
	<link rel="stylesheet" type="text/css"
		href="#{facesContext.externalContext.requestContextPath}/member/assets/css/jquery.dataTables.css" />

<rich:dataTable id="assetTrackingTravellingTable" ...


<rich:dataTable value="#{bean.list}" var="var">
    <f:facet name="noData">
        No data message
    </f:facet>
    <rich:column>
        <f:facet name="header"><h:outputText value="Field A"/></f:facet>
        <h:outputText value="#{var.fieldA}"/>
    </rich:column>
    ...
</rich:dataTable>
0

精彩评论

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