@Qualifier @Retention(value=RUNTIME) @Target(value={METHOD,FIELD,PARAMETER}) public @interface Cookie
The CDI annotation @
Cookie
allows you to inject a HTTP request cookie value from the current
JSF context in a CDI managed bean. It's basically like
@ManagedProperty("#{cookie.cookieName.value}") private String cookieName;
in a "plain old" JSF 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?
RequestCookieProducer
public abstract String name
Copyright © 2012–2020 OmniFaces. All rights reserved.