29.2. Annotations for bijection

The next two annotations control bijection. These attributes occur on component instance variables or property accessor methods.
@In
@In
Specifies that a component attribute is to be injected from a context variable at the beginning of each component invocation. If the context variable is null, an exception will be thrown.
@In(required=false)
Specifies that a component attribute is to be injected from a context variable at the beginning of each component invocation. The context variable may be null.
@In(create=true)
Specifies that a component attribute is to be injected from a context variable at the beginning of each component invocation. If the context variable is null, an instance of the component is instantiated by Seam.
@In(value="contextVariableName")
Specifies the name of the context variable explicitly, instead of using the annotated instance variable name.
@In(value="#{customer.addresses['shipping']}")
Specifies that a component attribute is to be injected by evaluating a JSF EL expression at the beginning of each component invocation.
  • value — specifies the name of the context variable. Defaults to the name of the component attribute. Alternatively, specifies a JSF EL expression, surrounded by #{...}.
  • create — specifies that Seam should instantiate the component with the same name as the context variable, if the context variable is undefined (null) in all contexts. Defaults to false.
  • required — specifies that Seam should throw an exception if the context variable is undefined in all contexts.
@Out
@Out
Specifies that a component attribute that is a Seam component is to be outjected to its context variable at the end of the invocation. If the attribute is null, an exception is thrown.
@Out(required=false)
Specifies that a component attribute that is a Seam component is to be outjected to its context variable at the end of the invocation. The attribute can be null.
@Out(scope=ScopeType.SESSION)
Specifies that a component attribute that is not a Seam component type is to be outjected to a specific scope at the end of the invocation.
Alternatively, if no scope is explicitly specified, the scope of the component with the @Out attribute issued (or the EVENT scope if the component is stateless).
@Out(value="contextVariableName")
Specifies the name of the context variable explicitly, instead of using the annotated instance variable name.
  • value — specifies the name of the context variable. Default to the name of the component attribute.
  • required — specifies that Seam should throw an exception if the component attribute is null during outjection.
These annotations commonly occur together, as in the following example:
@In(create=true) 
@Out private User currentUser;
The next annotation supports the manager component pattern, where a Seam component manages the life cycle of an instance of some other class that is to be injected. It appears on a component getter method.
@Unwrap
@Unwrap
Specifies that the object returned by the annotated getter method will be injected instead of the component.
The next annotation supports the factory component pattern, in which a Seam component is responsible for initializing the value of a context variable. This is especially useful for initializing any state required to render a response to a non-Faces request. It appears on a component method.
@Factory
@Factory("processInstance") 
public void createProcessInstance() { ... }
Specifies that the component method be used to initialize the value of the named context variable, when the context variable has no value. This style is used with methods that return void.
@Factory("processInstance", scope=CONVERSATION) 
public ProcessInstance createProcessInstance() { ... }
Specifies that the value returned by the method should be used to initialize the value of the named context variable, if the context variable has no value. This style is used with methods that return a value. If no scope is explicitly specified, the scope of the component with the @Factory method is used (unless the component is stateless, in which case the EVENT context is used).
  • value — specifies the name of the context variable. If the method is a getter method, this defaults to the JavaBeans property name.
  • scope — specifies the scope to which Seam should bind the returned value. Only meaningful for factory methods that return a value.
  • autoCreate — specifies that this factory method should be automatically called whenever the variable is asked for, even if @In does not specify create=true.
The following annotation lets you inject a Log:
@Logger
@Logger("categoryName")
Specifies that a component field is to be injected with an instance of org.jboss.seam.log.Log. For entity beans, the field must be declared as static.
  • value — specifies the name of the log category. Defaults to the name of the component class.
The final annotation lets you inject a request parameter value:
@RequestParameter
@RequestParameter("parameterName")
Specifies that a component attribute is to be injected with the value of a request parameter. Basic type conversions are performed automatically.
  • value — specifies the name of the request parameter. Defaults to the name of the component attribute.