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
408
votes
2 answers

How to choose the right bean scope?

I noticed that there are different bean scopes like: @RequestScoped @ViewScoped @FlowScoped @SessionScoped @ApplicationScoped What is the purpose of each? How do I choose a proper scope for my bean?
Valter Silva
  • 16,446
  • 52
  • 137
  • 218
267
votes
22 answers

BeanFactory vs ApplicationContext

I'm pretty new to the Spring Framework, I've been playing around with it and putting a few samples apps together for the purposes of evaluating Spring MVC for use in an upcoming company project. So far I really like what I see in Spring MVC, seems…
matt b
  • 138,234
  • 66
  • 282
  • 345
144
votes
18 answers

Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable

When trying to reference a managed bean in EL like so #{bean.entity.property}, sometimes a javax.el.PropertyNotFoundException: Target Unreachable exception is being thrown, usually when a bean property is to be set, or when a bean action is to be…
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
106
votes
6 answers

Get JSF managed bean by name in any Servlet related class

I'm trying to write a custom servlet (for AJAX/JSON) in which I would like to reference my @ManagedBeans by name. I'm hoping to map: http://host/app/myBean/myProperty to: @ManagedBean(name="myBean") public class MyBean { public String…
Konrad Garus
  • 53,145
  • 43
  • 157
  • 230
101
votes
2 answers

ViewParam vs @ManagedProperty(value = "#{param.id}")

What is the difference between defining View Params like this: And defining the property in the ManagedBean like this: @Inject @ManagedProperty(value =…
ehsun7b
  • 4,796
  • 14
  • 59
  • 98
68
votes
4 answers

Invoke JSF managed bean action on page load

Is there a way to execute a JSF managed bean action when a page is loaded? If that's relevant, I'm currently using JSF 1.2.
DD.
  • 21,498
  • 52
  • 157
  • 246
63
votes
3 answers

How to invalidate session in JSF 2.0?

What is the best possible way to invalidate session within a JSF 2.0 application? I know JSF itself does not handle session. So far I could find private void reset() { HttpSession session = (HttpSession) FacesContext.getCurrentInstance() …
Niks
  • 4,802
  • 4
  • 36
  • 55
62
votes
11 answers

Difference between managed bean and backing bean

I came across the terms "managed bean" and "backing bean" in several forums. Many people think both are the same. But, there seems to be a slight difference. Can any one help me to understand the exact difference between these two terms?
Krishna
  • 7,154
  • 16
  • 68
  • 80
60
votes
7 answers

WELD-001408: Unsatisfied dependencies for type Customer with qualifiers @Default

I'm a Java EE-newbie. I want to test JSF and therefore made a simple program but can not deploy it. I get the following error message: cannot Deploy onlineshop-war deploy is failing=Error occurred during deployment: Exception while loading the app :…
mike128
  • 609
  • 1
  • 5
  • 8
52
votes
4 answers

Spring JSF integration: how to inject a Spring component/service in JSF managed bean?

I understand that a managed bean works like a controller, because your only task is "link" the View Layer with Model. To use a bean as a managed bean I must declare @ManagedBeanannotation, doing that I can communicate JSF with bean directly. If I…
48
votes
6 answers

Calling a JavaScript function from managed bean

Is there a way to call (execute) a JavaScript function from managed bean in JSF? If that's relevant, I'm also using PrimeFaces.
Maddy
  • 3,726
  • 9
  • 41
  • 55
43
votes
3 answers

Canonical way to obtain CDI managed bean instance: BeanManager#getReference() vs Context#get()

I figured that there are two general ways to obtain an auto-created CDI managed bean instance via BeanManager when having solely a Bean to start with (which is created based on Class): By BeanManager#getReference(), which is more often shown…
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
42
votes
4 answers

How do I force an application-scoped bean to instantiate at application startup?

I can't seem to find a way to force an application-scoped managed bean to be instantiated/initialized when the web app is started. It seems that application-scoped beans get lazy-instantiated the first time the bean is accessed, not when the web app…
Jim Tough
  • 14,843
  • 23
  • 75
  • 96
42
votes
1 answer

Why are there different bean management annotations

What is the difference between import javax.annotation.ManagedBean; import javax.enterprise.context.SessionScoped; and import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; ?
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
40
votes
3 answers

JSF page redirecting from java bean

Is there some way how to redirect page to other page from Java method? I'm able only to forward it using: FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml"); or using navigation-rules of faces-config.xml. Do you have…
gaffcz
  • 3,469
  • 14
  • 68
  • 108
1
2 3
66 67