I have a JSF table which uses Hashmap to store selected checkboxes. My question is: Is it possible to use 2D Java array to store the keys instead of the Hashmap?
EDIT
I use this code to store the selected keys. How this code can be rewritten for Map?
private HashMap<String, Boolean> selected = new HashMap<>();
// send the list
public Map<String, Boolean> getselected() {
return selected;
}
My idea is to create 2D array(it will be used MAP) which will store the number of pages and the list on the pages. For example 100 pages x 10 keys.
EDIT 2
I created JSF table with lazy loading which takes data from Oracle. The JSF works very well and fast. The problem that I face is when I tried to create select all checkbox which takes all kays and stores the keys into hashmap. Later those keys will be used for SQL query to delete the rows which the user selects.
I created database table with 10 000 rows and displayed them into JSF table. When I clicked them all I created hashmap with 10 000. the performance is relatively good for that size. I tested to delete them - I created Java method which takes the generated hashmap and deletes the database rows using the keys stored into the hashmap. It's show but there can be done a few code optimizations.
The big problem is the scalability. I tested the hashmap with 1 000 000 keys - it works but it's terribly slow. I need to design the JSF table to handle very big data.
I think that the solution is to use 2D array (lets call it for this example). I will explain my idea this way:
I will have for example JSF table with 100 pages. Every page will have 10 rows. Into the standard hashmap I will have 1000 keys when I select all rows.
In 2D array solution I can create array with 100 elements and when I switch between the pages I will have only 10 rows which will be generated from the pagination code. When I select all database rows I can insert only the visible rows key into the 2D array. The other positions into the the array I replace with for example 1 in order to know that there is something. When I press the delete button the Java code will know that all elements are "virtually" selected. Is there a better and more simple solution?