4 Replies Latest reply on Feb 14, 2008 2:45 PM by sammy Jenkis

    NotLoggedInException

    Vincent Wiencek Newbie

      Hello,

      I've a xhtml page using a session bean to acces my entities. When I trying to access some entities, sometimes, for some entities, I need to be identified ...

      When I throw a NotLoggedInException, I get an error on the page. Why is'nt that exception caught by seam, to force a redirection to login.xhtml ?

      I can't use @Restrict, because I need to execute the method and query the entity to know if it is restricted.

      @Unwrap
       public Wedding getWedding() {
       if (wedding != null && wedding.getSiteName().equals(name))
       return wedding;
       try{
       wedding = (Wedding)em
       .createQuery("from Wedding where siteName like :name")
       .setParameter("name", name)
       .getSingleResult();
      
       if (wedding.getIsPrivate()){
       if (currentUser == null ||
       !currentUser.isAllowedToView(wedding)) {
       log.info("must be loggued");
       throw new org.jboss.seam.security.NotLoggedInException();
       }
       }
      
       return wedding;
       }
       catch (NoResultException e) {
       log.info("no existing wedding");
       }
       return null;
       }
      


      Is my code/question stupide ?

      Thx
      Vincent