-1

I'm creating two beans, make inject first bean to second bean. Second bean make set method for first bean. Also second bean bean called from JSF.

I need to container create one instance for access from second bean and JSF page.

Result page not include data from first bean, that has been set from second bean.

I think container create two instance. But why?

Thanks.

Code:

### first bean
@ManagedBean(name="a")
@Stateful

class A{

private String thing;

public String getThing();
public String setThing();

}
### second bean
@ManagedBean(name="b")
@SessionScoped
@Stateful

class B{

@Inject
private A a;

a.setThing();

}
### JSF page
<p:outputLabel value="#{a.thing}" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Sorry, of course, annotations ManagedBeans, Stateful and SessionScoped was written before class. But still does not work. – Pavel Shtykov Mar 11 '15 at 12:00
  • Check the packages of your annotations and use the link in my answer to check if you have the correct combinations – Kukeltje Mar 11 '15 at 12:18

1 Answers1

2

Your @ManagedBeans (it is @MangagedBean, without an s), @SessionScoped and @Stateful are positioned wrong. They should be above the class. And if you start using @Inject, might I suggest moving to the CDI based annotation @Named and its corresponding @SessionScoped (in a different pacakge). For the correct packages of annotations see here

Community
  • 1
  • 1
Kukeltje
  • 12,223
  • 4
  • 24
  • 47