2 Replies Latest reply on Sep 27, 2009 9:10 AM by Pieter Martin

    JSF and JPA

    Pieter Martin Novice


      I am using Web Beans 1.0.0 preview1 and JSF2.

      Following on from the login example I am trying to expose the user JPA entity directly to a jsf page.
      i.e. I do not want to reference the entity via some other WebBean.

      Previously in Seam all that was required was an @Out and voila the entity was available on a jsf page with el.

      I am struggling now to get the same right with @Produces.

      public class LoginController implements Serializable {
          private User user;
          public void login() {
           List<User> results = em
                          "select u from User u where u.username=:username and u.password=:password")
                     .setParameter("username", credentials.getUsername())
                     .setParameter("password", credentials.getPassword())
           if (!results.isEmpty()) {
               user = results.get(0);
               new FacesMessage("Welcome, " + user.getName()));
          public User getUser() {
              return user;
          public void setUser(User user) {
              this.user = user;

      On the jsf page then

      <h:outputText value="#{user.username}"/>

      The User class has a

      @Named("user") @ConversationScoped

      Somehow I think I am misunderstanding how this is suppose to work.

      Any help appreciated