2 Replies Latest reply on Jun 1, 2007 4:20 AM by limousyf

    @In ? I don't get it ...

    limousyf

      Hello,

      I'm using a seam-gen generated application and I try to force the login when accessing the application because I always need a logged user in the session context (all data managed is linked to this logged user).

      So I'm redirecting to login.seam instead of home.seam in index.xhtml but, when the login page is displayed I got this error:


      javax.faces.el.EvaluationException: Cannot get value for expression '#{certificationList.firstResult}'

      (...)

      org.jboss.seam.RequiredException: In attribute requires non-null value: myCertifications.loggedCollaborateur


      "certificationList" is the datamodel I'm using in another page in the application (not login.xhtml). It's used for a datatable.
      In the factory method of this datamodel, I'm using the "loggedCollaborateur" to restrict the list so it cannot be null, seam is right.
      But why is seam calling this "#{certificationList.firstResult}" before any login ?

      By the way, here's my authenticator :

      @Out(value="loggedCollaborateur", scope=ScopeType.SESSION)
      Collaborateur loggedCollaborateur;

      public boolean authenticate() {

      log.info("authenticating #0", Identity.instance().getUsername());
      if(em == null){log.error("Could not authenticate because EntityManager null."); return false;}
      List users = em.createQuery("select u from User u where login_name=:username and password=:password")
      .setParameter("username", Identity.instance().getUsername())
      .setParameter("password", Identity.instance().getPassword())
      .getResultList();
      if(users.size() == 0) {
      return false;
      } else {
      User user = users.get(0);
      //fetch the collaborateur for this user
      List colabs = em.createQuery("select c from Collaborateur where c.user_id=:userId")
      .setParameter("userId", user.getUserId())
      .getResultList();

      loggedCollaborateur = colabs.get(0);

      identity.addRole("admin");
      }
      return true;
      }


      And in the bean(s) using this outjected Collaborateur Object, I have:

      @In(value="loggedCollaborateur")
      Collaborateur loggedCollaborateur;

      and then using this object to restrict my data.

      Am I doing something wrong here ?
      Lots of things wrong ?
      Why is there this .firstResult call and how can I avoid the null value check before any login ?

        • 1. Re: @In ? I don't get it ...
          peter2

          Use the force luke ;-)

          No, to solve this you could create a home.page.xml and put following in it:

          <!DOCTYPE page PUBLIC
           "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
           "http://jboss.com/products/seam/pages-1.2.dtd">
          
          <page no-conversation-view-id="/home.xhtml"
           login-required="true">
          </page>


          this will force a login from the beginning.

          Hopefully this works.


          Greetz,
          Pjotr


          PS: if someone thinks that's not the way to go please tell me....

          • 2. Re: @In ? I don't get it ...
            limousyf

            Yes, that's what I did, even if I don't know for the moment what these .page.xml files are (supposely pageflow stuff, I'll read the doc ...)

            The only problem occur when I clicked the "logout" link. The navigation displayed the home page without asking for login.
            Still a lack of pageflow-knowledge I guess ...

            By the way thank you for your answer