All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.seam.core.ConversationStack Maven / Gradle / Ivy

There is a newer version: 3.2.26.ayg
Show newest version
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 {

	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();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy