Here's a little tips to show only the top level conversations from the list of active conversations.
If we have theses conversations (with nested conversations (>)):
A1 > A2 > A3
B1 > B2
C1
With the conversationList component you will see every conversations.
A1
A2
A3
B1
B2
C1
With the new component below you will see only the root conversations:
A3
B2
C1
My customer prefered to see only the root conversation and not the entire active conversations
@Scope(ScopeType.PAGE) @Name("rootConversationList") @Intercept(NEVER) public class RootConversationList implements Serializable { private List<ConversationEntry> conversationEntryList; @Create public void createConversationEntryList() { Map<String, ConversationEntry> map = Manager.instance().getConversationIdEntryMap(); Set<ConversationEntry> orderedEntries = new TreeSet<ConversationEntry>(); orderedEntries.addAll(map.values()); // Accumulates nested conversations Set<String> nestedConversationEntrySet = new HashSet<String>(); for (ConversationEntry entry : orderedEntries) { if (entry.isDisplayable() && !Seam.isSessionInvalid()) { boolean skip = true; for (String conversationId : entry.getConversationIdStack()) { // The first nested conversation is always itself so we skip this one if (!skip) { nestedConversationEntrySet.add(conversationId); } skip = false; } } } this.conversationEntryList = new ArrayList<ConversationEntry>(map.size()); for (ConversationEntry entry : orderedEntries) { if (entry.isDisplayable() && !nestedConversationEntrySet.contains(entry.getId()) && !Seam.isSessionInvalid()) { this.conversationEntryList.add(entry); } } } @Unwrap public List<ConversationEntry> getConversationEntryList() { return this.conversationEntryList; } }
Comments