I think there could be two problems in the following method:
1
2 public List<BattlecardEntry> getBattlecards() {
3 battlecards = (List<BattlecardEntry>) ApplicationAttribute
4 .getApplicationAttribute(CURRENT_BATTLECARDS_KEY);
5 // we only want to sortColumnName if the column or ordering has changed.
6 if (!oldSort.equals(sortColumnName) || oldAscending != ascending) {
7 sort();
8 oldSort = sortColumnName;
9 oldAscending = ascending;
10 }
11
12 SessionRenderer.render(groupName);
13 return battlecards;
14 }
1) Performance: Since managed-bean getter methods can be called many many times during the execution of the JSF lifecycle, the recommended practice is to always use lazy-initialization. For example:
1
2 public List<BattlecardEntry> getBattlecards() {
3
4 if (battlecards == null) {
5 battlecards = (List<BattlecardEntry>) ApplicationAttribute
6 .getApplicationAttribute(CURRENT_BATTLECARDS_KEY);
7 // we only want to sortColumnName if the column or ordering has changed.
8 if (!oldSort.equals(sortColumnName) || oldAscending != ascending) {
9 sort();
10 oldSort = sortColumnName;
11 oldAscending = ascending;
12 }
13
14 SessionRenderer.render(groupName);
15 }
16 return battlecards;
17 }
I would also recommend that you put in a System.err.println at the top of the method to see how often it gets called. I bet it's called a lot.
2) The call to SessionRenderer.render(groupName) should not be in a getter-method like this. Instead, it should be called when a button is clicked by the user, or when an asynchronous event happens on the server. Also because of problem#1, the call to SessionRenderer.render(groupName) is probably happening a bunch of times.
Please sign in to flag this as inappropriate.