6 Replies Latest reply on Oct 3, 2007 9:54 AM by oblivion1200

    Logging in and null outjected objects

    oblivion1200

      Hello, I have problem with logging in and outjected objects.

      I have two xhtml pages. First is visible for all, second only to logged users. The first page has link to second page. When I click on that link, user object is outjected

      @Out(required=false,scope=ScopeType.SESSION)
       private Users user;

      The second page has to display info about this user.

      I have restriced acces to second page
      <page view-id="/user.xhtml" login-required="true" />

      so now when I click on link and I am not logged in I get redirected to login page. Then I log in and there is no user object outjected. Second page displays invalid data (nulls).

      If I log in first and after that go to first page and click the link, it works ok.

      Is there any way to solve this problem?


      Thanks in advance

        • 1. Re: Logging in and null outjected objects
          pmuir

          The code you have posted doesn't show how you make the outjection happen (perhaps you need a @Factory?)

          • 2. Re: Logging in and null outjected objects
            oblivion1200

            I am not logged in now. I click on that link on first page

            <s:link view="/user.xhtml" action="#{bidder.outjectUser()}" value="#{auction.users.login}"/>
            


            bidder object
            @Stateful
            @Name("bidder")
            public class Bidder implements _Bidder
            {
             @In(required=false)
             private Auctions auction;
            
             @PersistenceContext(type=PersistenceContextType.EXTENDED)
             private EntityManager entityManager;
            
             @Out(required=false,scope=ScopeType.SESSION)
             private Users auctionUser;
            
             public void outjectUser(){
             auctionUser = auction.getUser();
             }
            


            Here goes logging, because:
            <page view-id="/user.xhtml" login-required="true" />
            


            second page - user.xhtml
            <h:outputText value="Nick"/>:<h:outputText value="#{auctionUser.login}"/><br/>
            <h:outputText value="Imie"/>:<h:outputText value="#{auctionUser.name}"/><br/>
            


            Outjection works ok when I am logged in. If I am not logged in , the login process erases outjected auctionUser and no value on user.xhtml is displayed.

            • 3. Re: Logging in and null outjected objects
              pmuir

              Using both an action and a view on s:link is a little odd. Try designing your app so you use one or other.

              • 4. Re: Logging in and null outjected objects
                oblivion1200

                It is my first seam application. Probably I made some design mistakes. I use both view and action on s:link, because I need to have outjected auctionUser to display on user.xhtml. User.xhtml has no backing bean, it only dispalys properties of outjected object. This object may come from many different beans. I don't need to outject auctionUser if someone don't go to user.xhtml. Should I use

                 <page view-id="*">
                 <navigation from-action="#{bidder.outjectUser}">
                 <redirect view-id="/user.xhtml"/>
                 </navigation>
                

                instead of
                <s:link view="/user.xhtml"
                

                ?

                • 5. Re: Logging in and null outjected objects
                  pmuir

                  Yes. I'm not sure if this will help with your exact problem, but it is much better :)

                  • 6. Re: Logging in and null outjected objects
                    oblivion1200

                    Wow, it works now. Code like this does not work

                     <page view-id="*">
                     <navigation from-action="#{bidder.outjectUser}">
                     <redirect view-id="/user.xhtml"/>
                     </navigation>
                    

                    I had to use
                     <page view-id="*">
                     <navigation from-action="#{bidder.outjectUser()}">
                     <redirect view-id="/user.xhtml"/>
                     </navigation>
                    


                    Thanks Pete for your help.