How do I use a managed bean in another managed bean

I have two managed beans. One is backing bean for a form and the other is used to access a database table.

1st bean

public class TestDBAO

{

@PersistenceContext

private EntityManager em;

public void addEntry(PersonObj person)

{

em.persist(person);

}

}

public class formdata

{

private String id;

private String fname;

private String lname;

getter functions

setter functions

public String submit()

{

in here i want to call addEntry function from TestDBAO

}

}

How can I achieve this or is there another way to do this?

[660 byte] By [ashrestha] at [2007-10-3 3:30:49]
# 1

Do I understand correctly that you have definied TestDBAO as a session scoped managed bean? Why?

You don't need that. Just create and call TestDBAO in the backing bean. Or if you want only one instance of TestDBAO during the session, then create a singleton constructor and eventually make the methods static.

BalusCa at 2007-7-14 21:24:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...