Questions tagged [managed-bean]

"Managed bean" is a Java EE specific term for Javabean classes which are designed to act as a controller in some MVC application. They are often referred in context of JSF and CDI.

"Managed bean" is a Java EE specific term for Javabean classes which are designed to act as a controller in some MVC application. They are often referred in context of JSF and CDI.

1004 questions
17
votes
1 answer

How and when is a @ViewScoped bean destroyed in JSF?

The lifecycle of the @RequestScoped and @SessionScopedBean managed beans are managed by the Servlet container itself since they are basically stored as an attribute of HttpRequest and HttpSession respectively. How do JSF manage the lifecycle of the…
Geek
  • 26,489
  • 43
  • 149
  • 227
16
votes
1 answer

Cannot access inner class in bean

I'm using JSF 2.0. I have a managed bean which I can access through my xhtml page. Inside the bean I declared an inner class. I can access ArrayList of managed bean but not ArrayList and I get the error that the InnerClass does…
user579674
  • 2,159
  • 6
  • 30
  • 40
16
votes
2 answers

How to redirect from a ManagedBean for when the request sent is an Ajax request?

I am using PrimeFaces with JSF2. I am trying to authenticate user by sending login and password as an Ajax request. And in the action method of the backing bean, I am trying to validate user and redirect to a new view if the validation succeeds. Is…
Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
15
votes
1 answer

Illegal Syntax for Set Operation

I have a problem in connecting My xhtml page to the managed bean, the action on the commandButton works but when it comes to passing values it doesn't work. here is my jsf code:
14
votes
1 answer

what to use, managed beans (backing beans) or entity beans?

I see a lot of examples marking beans as entity beans (@Entity) & named beans (CDI), so as to avoid creating 2 classes (managed bean & entity bean) and also to make use of Bean Validation so that validation can be performed on both client &…
Abdullah Shaikh
  • 2,567
  • 6
  • 30
  • 43
14
votes
4 answers

What is the equivalent of @ManagedBean(eager=true) in CDI

As we all know that it is recommended to use annotations from javax.enterprise.context instead of javax.faces.bean as they are getting deprecated. And we all found ManagedBeans with eager="true" annotated with @ApplicationScoped from…
Jalal Sordo
  • 1,605
  • 3
  • 41
  • 68
13
votes
2 answers

com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean

I have a JSF managedbean I am getting the error when a managed bean is referred from from JSF page in WebSphere AppServer. The bean is defined in the faces-config.xml as
greg
  • 237
  • 1
  • 4
  • 8
13
votes
1 answer

How to send form input values and invoke a method in JSF bean

I am building a JSF application. I defined the GUI and did the select statements query the database using select. Now I must do the insert statements, but I don't know how to read the value of a JSF input component like and send it to…
Mircea
  • 3,369
  • 6
  • 27
  • 26
13
votes
2 answers

NullPointerException while trying to access @Inject bean in constructor

I've a session scoped bean: @Named @SessionScoped public class SessionBean implements Serializable { private String someProperty; public String getSomeProperty() { return someProperty; } } I'd like to inject this in a request…
eric.itzhak
  • 15,752
  • 26
  • 89
  • 142
13
votes
3 answers

Read resource bundle properties in a managed bean

Using files I'm able to have i18n text in my JSF pages. But is it possible to access these same properties in my managed bean so I can set faces messages with i18n values?
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
13
votes
2 answers

Inject vs ManagedProperty

Okay, so I have a JSF backing bean that needs a reference to another (@NoneScoped) bean. Should I @Inject it or use @ManagedProperty to obtain an instance reference from the container? Why use one and not the other, in my mind the two approaches…
maralbjo
  • 963
  • 1
  • 10
  • 16
12
votes
1 answer

Getting a path to a resource file from managed-bean in JSF

I have this situation: I am trying to remove an old avatar image for a user before putting a new one from the managed bean. String fileName = "resources/img/useravatars/" + getSessionBean().getSearchAccount().getAvatar(); File f = new…
Pavlo Bazilnskyy
  • 336
  • 2
  • 6
  • 18
12
votes
1 answer

sessionscoped managed bean vs stateful ejb

If I have a @ManagedBean that's @SessionScoped, why would I use a @Stateful EJB? I used it before for shopping carts and maintaining a conversational state, but since a managed bean will be kept during the user session I can store state there, then…
arg20
  • 4,893
  • 1
  • 50
  • 74
12
votes
1 answer

Migrate JSF managed beans to CDI managed beans

I'm planning to convert a web app from using JSF managed bean to using CDI managed beans. I know I'll need to do below: Add a empty beans.xml file in WEB-INF. Replace all JSF @ManagedBean to CDI @Named annotations. Replace all JSF scope annotations…
HockChai Lim
  • 1,675
  • 2
  • 20
  • 30
12
votes
1 answer

Injecting all beans of the same type with CDI

Suppose we have a package foos containing classes, which all of them implements some IFoo. We also have a class, Baz which contains a data-member, List fooList. Is it possible to inject dynamically all those IFoo classes into fooList? By the…
Elimination
  • 2,619
  • 4
  • 22
  • 38
1 2
3
66 67