JSF2 - h:dataTable Demo using HashMap

 The data table component in JSF2 is used for displaying database table, array list, hash map, etc.., into tabular format. In JSP, if you want to display a table record in tabular format, we need to create a html table template after that we need to iterate the result set object. Here that is not necessary, because the h:dataTable automatically create a table template based on your inputs as well it have lot of useful attributes for specifying style class for HTML tags like table, th, tr and td.
 This is very simple use case of h:dataTable. Here I am using HashMap, Inside the hash map I have all country name as key and corresponding capital name as value. Now I am going to display that hash map into tabular format using h:dataTable component. 

			
				
			
			
				
					
				
				
			
			
				
					
				
				
			
			
				
			
		
 The rowClasses, columnClasses, header and footer classes are very useful attributes used for define your own css classes into table attributes. Download my entire application from github and see my managed bean, xhtml and css code. The result of application is like this.


Comments

Popular Posts