此内容没有您所选择的语言版本。

29.2. Annotations for bijection


The next two annotations control bijection. These attributes occur on component instance variables or property accessor methods.
@In
@In
Copy to Clipboard Toggle word wrap
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)
Copy to Clipboard Toggle word wrap
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)
Copy to Clipboard Toggle word wrap
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")
Copy to Clipboard Toggle word wrap
Specifies the name of the context variable explicitly, instead of using the annotated instance variable name.
@In(value="#{customer.addresses['shipping']}")
Copy to Clipboard Toggle word wrap
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
Copy to Clipboard Toggle word wrap
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)
Copy to Clipboard Toggle word wrap
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)
Copy to Clipboard Toggle word wrap
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")
Copy to Clipboard Toggle word wrap
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;
Copy to Clipboard Toggle word wrap
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
Copy to Clipboard Toggle word wrap
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() { ... }
Copy to Clipboard Toggle word wrap
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() { ... }
Copy to Clipboard Toggle word wrap
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")
Copy to Clipboard Toggle word wrap
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")
Copy to Clipboard Toggle word wrap
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.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat