Skip to content

Instantly share code, notes, and snippets.

@rynmrtn
Created January 4, 2010 18:03
Show Gist options
  • Save rynmrtn/268694 to your computer and use it in GitHub Desktop.
Save rynmrtn/268694 to your computer and use it in GitHub Desktop.
Notes on Seam Framework

JSF and RichFaces Notes

Validators:

<!-- Combination of rich:beanValidator and a4j:support. This will bind to the hibernate validators for the model and
     validate when the field is no longer in focus (onblur). The event could be any supported event.
-->
<rich:ajaxValidator event="onblur" />

<!-- Which is equivalent to -->
<rich:beanValidator>
   <a4j:support event="onblur" />
</rich:beanValidator>

<!-- Only work on submit. These should bind to the model and use, for example, the hibernate validators -->
<s:validate />
<rich:beanValidator />

In Java (in a hibernate domain object), you can do something like the following:

@Entity
public class MyObject {
   @NotNull
   @Length(min = 3, message="This field must be at least {min} characters")
   private String str;

   // Getters and Setters, etc.
}

Seam Component Lifecycle

Seam has the following stateful contexts:

  1. Stateless: Component does not contain any state data.
  2. Event: Component maintains its state during the processing of a single JSF request.
  3. Page: Component maintains state for all events associated with a single page.
  4. Conversation: Component maintains state for the duration of a conversation. A conversation is defined specifically to be a series of requests that make up a process. Each conversation is defined based on the business rules of an application.
  5. Session: Components maintains state in an HTTP session object until the session expires.
  6. Business Process: Components are associated with a long-running business process managed by JBoss jBPM (Business Process Manager) engine. Business processes can span across several users and sessions.
  7. Application: A global context that holds information that will never expire (unless a server process is restarted or the power goes out, etc.)
/**
Events: http://docs.jboss.com/seam/2.1.0.GA/api/org/jboss/seam/core/Events.html
*/
Events.instance().raiseEvent(/**/)
/**
Contexts: http://docs.jboss.org/seam/2.0.1.CR1/api/org/jboss/seam/contexts/Contexts.html
*/
Contexts.removeFromAllContexts("")
// Contexts.getXYZContext(/**/).get/set, i.e.
Contexts.getConversationContext.set("name", valueVariable)
Contexts.getConversationContext.get("name")
// Search through the contexts for a component of the given string name. This can be
// either an action class or a variable outjected to the context.
Components.getInstance("name")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment