• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF + JPA how to use together

 
Ramil Huseynov
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to do simple impute on JSF

<h:form>
<h:inputText value="#{person.name}"/>
<h:inputText value="#{person.lastname}"/>
<h:commandButton value="ok" action="submit"/>
</h:form>

but a little bit confused. JSF use managed bean. JPA use EntityBean. how to bind them, or use one class as Entity and Managed bean at the same time?
I red about DAO(Data access object), about injection, session beans, but did not understand how to use them in action. Can you give me a link to tutorial, where input used. All tutorials work with full database, and only read from database, but i need insert data.
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Ramil!

I was scratching my head over what you meant by "doing a simple impute", but then I realized you meant "input". "Impute" is a valid English word, although not that much used except maybe by lawyers these days.

It is not recommended to try and use Domain Model (JPA) objects directly as JSF backing beans or injected into JSF backing beans. The JSF auto-wiring mechanism isn't designed to work with multiple instances of objects where the instance being wired changes over time. So normally you use a JSF MVC Model object (backing bean) as a fa├žade and access the Domain Model object through the backing bean's properties.

It's common practice to inject or construct a persistence interface object such as an EJB session bean or a DAO into a JSF backing bean. You would then use this access object to read and update the database data.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!