Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

22.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. Default 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. Default to false.
  • required — specifies 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 may 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 is used (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 Seam should throw an exception if the component attribute is null during outjection.
Note that it is quite common for these annotations to occur together, for example:
@In(create=true) @Out private User currentUser;
The next annotation supports the manager component pattern, where a Seam component that manages the lifecycle 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 is the thing that is injected instead of the component instance itself.
The next annotation supports the factory component pattern, where a Seam component is responsible for initializing the value of a context variable. This is especially useful for initializing any state needed for rendering the response to a non-faces request. It appears on a component method.
@Factory
@Factory("processInstance")
Specifies that the method of the component is 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)
Specifies that the method returns a value that Seam should use to initialize the value of the named context variable, when 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, default to the JavaBeans property name.
  • scope — specifies the scope that Seam should bind the returned value to. Only meaningful for factory methods which return a value.
This 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. Default to the name of the component class.
The last 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. Default to the name of the component attribute.

 
 
  Published under the terms of the Open Publication License Design by Interspire