org.jboss.seam.core.ConversationStack Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jboss-seam Show documentation
Show all versions of jboss-seam Show documentation
Seam core module for Seam framework integrated with JSF2
package org.jboss.seam.core;
import static org.jboss.seam.ScopeType.PAGE;
import static org.jboss.seam.annotations.Install.BUILT_IN;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.web.Session;
/**
* Factory for the "breadcrumbs", a stack with all
* parent conversations of the current conversation.
*
* @author Gavin King
*/
@Scope(ScopeType.STATELESS)
@Name("org.jboss.seam.core.conversationStackFactory")
@Install(precedence = BUILT_IN)
@BypassInterceptors
public class ConversationStack {
public ConversationStack() {
super();
}
protected List createConversationEntryStack() {
ConversationEntries conversationEntries = ConversationEntries.getInstance();
if (conversationEntries == null) {
return Collections.emptyList();
} else {
ConversationEntry currentConversationEntry = Manager.instance().getCurrentConversationEntry();
if (currentConversationEntry == null) {
return Collections.emptyList();
} else {
List idStack = currentConversationEntry.getConversationIdStack();
List conversationEntryStack = new ArrayList(conversationEntries.size());
ListIterator ids = idStack.listIterator(idStack.size());
while (ids.hasPrevious()) {
ConversationEntry entry = conversationEntries.getConversationEntry(ids.previous());
if (entry.isDisplayable() && !Session.instance().isInvalid()) {
conversationEntryStack.add(entry);
}
}
return conversationEntryStack;
}
}
}
@Factory(value = "org.jboss.seam.core.conversationStack", autoCreate = true, scope = PAGE)
public List getConversationEntryStack() {
return createConversationEntryStack();
}
}