The CDI annotation @Cookie allows you to inject a HTTP request cookie value from the current
Faces context in a CDI managed bean. It's basically like
@ManagedProperty("#{cookie.cookieName.value}") private String cookieName;
in a "plain old" Faces managed bean.
By default the name of the cookie is taken from the name of the variable into which injection takes place.
The example below injects the cookie with name foo.
@Inject @Cookie private String foo;
The name can be optionally specified via the name attribute.
The example below injects the cookie with name foo into a variable named bar.
@Inject @Cookie(name="foo") private String bar;
Validation is by design not supported as cookies are usually beyond enduser's control. TODO: conversion?
- Since:
- 2.1
- Author:
- Bauke Scholtz
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
name
String name(Optional) The name of the request cookie. If not specified the name of the injection target field will be used.- Returns:
- The name of the request cookie.
- Default:
- ""
-