Understanding Seam Contexts

From Shrubbery

Jump to: navigation, search


What are Seam Contexts?


The list of contexts

ContextDescription
method
event
  • Basically equivalent to the HttpServletRequest. Populated with values from the HttpServletRequest (if there is one).

See ScopeType.EVENT

page
  • Unique to seam, this context exists from the INVOKE_APPLICATION phase to the next INVOKE_APPLICATION on any JSF request coming from the page. This context is one way to pass things from one action method to another, or from an action method to a rendered page through a redirect without having a conversation.
  • Note: Page scope only works with JSF requests (commandLink, commandButton). It does not work with restful links. Conversation scope is better for retaining context across restful links.

See: ScopeType.PAGE

conversation
  • Unique to Seam, this is a 'sub-session', or a workspace.
  • Every request in Seam has a default conversation. This context and all it's components will last until the next page is rendered.
  • If the conversation is promoted to a long running conversation (maybe there is an action method with @Begin), then the context and all it's components will last until the conversation is ended or timed out.
  • Seam can automatically ensure that an EntityManager will be available for the entire conversation. This is useful for eliminating the dreaded LazyIntializationException from Hibernate, and it works with both temporary (defatlt) conversations and long running conversations.
session
  • Basically equivalent to the HttpServletSession. Populated with values from the HttpServletSession (if there is one).
businessProcess
application
  • Global context for the whole application.
  • Basically equivalent to the ServletContext. Populated with values from the ServletContext.
Personal tools