Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1124

Public fields in CDI

$
0
0
in CDI one can't have a PUBLIC attribute in a RequestScoped variable:


@Named
@RequestScoped
public class EventViewBean implements Serializable {

@Produces
public List<Meal> meals;

public void setMeals(List<Meal> meals) {
this.meals = meals;
}

public List<Meal> getMeals() {
return meals;
}

}

otherwise you get this error:

WELD-000075 Normal scoped managed bean implementation class has a public field

To fix the issue, just remove the "public" in "public List<Meal> meals;" and don't ask questions... it's all too sad... just smile and say yes.

Viewing all articles
Browse latest Browse all 1124

Trending Articles