@ManagedProperty is not working in a managedbean

asked 08.04.2015 at 08:57

nwk2Team's gravatar image

nwk2Team
16448
accept rate: 0%


I can not say why it is not supported, but I can give you a workaround, how you can access another ManagedBean in a ManagedBean or other Java Code:

ELContext elContext = FacesContext.getCurrentInstance().getELContext();
MyOtherManagedBean myOtherManagedBean = (MyOtherManagedBean) FacesContext.getCurrentInstance()
    .getApplication().getELResolver().getValue(elContext, null, "myOtherManagedBean");

The Bean which we access could look like this:

@ManagedBean(name = "myOtherManagedBean")
@RequestScoped
public class MyOtherManagedBean {
...
}
link

answered 08.04.2015 at 09:09

Christian%20Strebel's gravatar image

Christian St... ♦
2.9k21231
accept rate: 90%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×73
×45

Asked: 08.04.2015 at 08:57

Seen: 2,233 times

Last updated: 08.04.2015 at 09:40