• Post Reply Bookmark Topic Watch Topic
  • New Topic

datatable iteration  RSS feed

 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
In my database i have 2 rows and i am displaying these 2 rows using
<h:dataTable>.
But i have to show 24 rows initially.Based on the condition i need to
fill the data in the dataTable.

i have to display like this:
Hour Task
1
2
. Meeting
.
. Chatting
24
But in my database i have 2 rows (2 bean objects in a list), so only
2 rows are displaying.

How can i iterate datatable 24 times and based on the time populate
the data from the list of beans

Thanks,
siraj.
 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any Help?
 
Arshad Sharief
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dataTable will loop thru the list which you have supplied.


what are you trying to achieve.. need more info


Arshad.
 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arshad,All

I have to display Hours and Task on datatable.
Hours from 1 to 24 [static].
In my database i have task table which is like:

taskid taskdate tasktime task
1 28-06-2008 8:00 Meeting
2 28-06-2008 10:00 Interview
3 28-06-2008 12:00 xxxxxx

I have to show in my data table like this

Hour Task
1
2
.
8 Meeting
.
10 Interview
.
.
24

The hours which are not there in database left blank.
Here in the datatable i have to populate 24 hours.and for a perticular
hour show the task.

when i issue the query based on the date my list contains only 3 beans.
so datatable getting populaed with 3 rows.But i want 24 rows.

Please suggest me best design for this.


Thanks,
Siraj.
 
Arshad Sharief
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your bean initialize a HashMap's key with 1 to 24 and match your time with the key, if it matches assign the task to the key. Since you are retrieving data by date I think this will work.

HashMap does not guarantee the order of the keys, instead use LinkedHashMap.


Arshad.
 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replay Arshad.
Here i have a small problem.HashMap/Hashtable will not have duplicate
keys.Assume If i have two tasks at a same time then?
 
Arshad Sharief
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How come one person will have two tasks at the same time?? either he will have a meeting or interview or appointment...


can you give me an example?


Arshad.
 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i also assume there are no two tasks at same time.
I tryed iterating with hashmap.But it is not working.
I googled around and found that hashmap will not iterate.it is used to
display only.
If in my hash map i have key is "hour" and value is "bean obj"
and i have 24 key value pairs.Now i want to display key,values.
 
Arshad Sharief
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using HashMap's entryset() assigned to a list, you can display the key and values in af:table.


Arshad.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!