1 2 Previous Next 15 Replies Latest reply on Nov 25, 2007 3:33 PM by whafrog

    problem in login.seam

    panky_p Novice

      Hi,
      I am newbie to seam and using jboss-4.2.0.GA and jboss-seam-2.0.0.BETA
      I am trying to build simple application for login-logout
      when I try url http://localhost:8080/mypage it redirect to http://localhost:8080/mypage/login.seam?conversationId=1
      and shows message below login button - Please log in first.
      but when I try direct url http://localhost:8080/mypage/login.seam it doesn't show above message.
      I am trying to figure out the problem but unable to get it., as i don't want that message to be shown when i first time link to login page.
      Is there any help !!

        • 1. Re: problem in login.seam
          Stuart Douglas Master

          When you try and access the main page (index.seam or whatever) seam detects that you have not logged in yet and throws a NotLoggedInException.
          It then redirects you to the login page and adds 'Please login first' to the FacesMessages (which are displayed via the s:messages component) . The message is controlled in pages.xml as specified in section 13 of the docs.

          When you just go the the login page without the NotLoggedInException beging thrown the message is not added. If you really want it you could try one of the following:

          - Just use a static Message
          - Add a page action with something like:

          public void PageAction()
          {
          if(FacesMessages.instance().getMessages().isEmpty())
          FacesMessages.instance().add("Please Log in first")
          }

          Hope this helps.

          • 2. Re: problem in login.seam
            panky_p Novice

            Thank you swd847 !!

            But i don't want that message to be displayed.
            and I have tried it as

            public void PageAction()
            {
            if(FacesMessages.instance().getMessages().isEmpty())
            FacesMessages.instance().add(" ")
            }


            but it is not working. and displays same message
            "Please Log in first"
            Is there any other way??

            • 3. Re: problem in login.seam
              Curtney Jacobs Newbie

              I believe I may have came accross a post that said the default messages are controlled by the message.properties file.

              I believe it is the same way you controll JSF default error messages, by overriding. In your case, you would just leave it blank.

              like:

              org.jboss.seam.somethng=


              Do a search on the forum using "messages" as a keyword

              • 4. Re: problem in login.seam
                Shane Bryzak Master

                If you don't want the messages use identity.authenticate instead of identity.login.

                • 5. Re: problem in login.seam
                  panky_p Novice

                  hello curtney,
                  I have tried it with

                  org.jboss.seam.NotLoggedIn=

                  in message.property but it is not working,

                  And shane
                  i have tried it with identity.authenticate instead of identity.login. Still it shows the same message and when i try to login with incorrect username and password it shows complete exception message insted of message "Invalid User" which i want to display!!

                  • 6. Re: problem in login.seam
                    panky_p Novice

                    I am trying in my login page

                    <tr>
                    <td>
                    <h:commandButton type="submit" value="Login" action="#{identity.login}"/>
                    </td>
                    </tr>
                    <tr>
                    <td colspan="2" align="center">
                    <h:message for="" style="color:red"/></td>
                    </tr>
                    

                    and in pages.xml
                    <pages xmlns="http://jboss.com/products/seam/pages"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xmlns:s="http://jboss.com/products/seam/taglib"
                     xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-1.3.xsd"
                    no-conversation-view-id="/login.xhtml"
                     login-view-id="/login.xhtml">
                    <page view-id="*">
                     <navigation from-action="#{identity.logout}">
                     <redirect view-id="/login.xhtml"/>
                     </navigation>
                     </page>
                    
                     <page view-id="/login.xhtml">
                     <navigation>
                     <rule if="#{identity.loggedIn}">
                     <redirect view-id="/main.xhtml"/>
                     </rule>
                     </navigation>
                     <navigation from-action="#{identity.login}">
                     <redirect view-id="/main.xhtml"/>
                     </navigation>
                     </page>
                    <exception class="org.jboss.seam.security.AuthorizationException">
                     <redirect view-id="/error.xhtml"/>
                     </exception>
                    
                     <exception class="javax.security.auth.login.LoginException">
                     <redirect view-id="/login.xhtml"/>
                     </exception>


                    And when i try to login.seam it gives me a message "Please log in first"
                    but i dont want that message to be displayed when first time i visit to login page.
                    Thanks for the reply, i am trying all the suggestions given by forum,
                    but i am still not getting how to remove that message!!
                    is there any thing wrong in my code??

                    • 7. Re: problem in login.seam
                      Shane Bryzak Master

                      Sorry, I misunderstood your original question. You need to add the following entry to your messages.properties file (not message.property):

                      org.jboss.seam.NotLoggedIn=


                      I've just updated the seambay example in CVS to do just this.

                      • 8. Re: problem in login.seam
                        panky_p Novice

                        Yes Shane,
                        I did try on messages.properties by adding

                        org.jboss.seam.NotLoggedIn=

                        but it still shows the message "Please log in first"
                        I am also trying to find out whether it is maintaining
                        session somewhere or not ?
                        I think quite possible it may be a reason!!

                        Thanks for reply!!

                        • 9. Re: problem in login.seam
                          Stuart Douglas Master

                          I have two simple and rather dodgy ways to work around this:

                          1) remove <s:messages/> from the login page.

                          2)
                          Try something like:

                          Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages();
                           while ( iter.hasNext() )
                           {
                           FacesMessage m = (FacesMessage)iter.next();
                           if(m.getDetail().equals("Please log in first")
                           iter.remove();
                          
                           }
                          
                          


                          The code above probably won't work, but you get the general idea.

                          • 10. Re: problem in login.seam
                            Stuart Douglas Master

                            The code in question looks like:

                             protected void notLoggedIn()
                             {
                             Events.instance().raiseEvent("org.jboss.seam.notLoggedIn");
                            
                             FacesMessages.instance().addFromResourceBundleOrDefault(
                             FacesMessage.SEVERITY_WARN,
                             "org.jboss.seam.NotLoggedIn",
                             "Please log in first"
                             );
                             }
                            


                            So there is no way to stop something being added to the faces messages.

                            • 11. Re: problem in login.seam
                              panky_p Novice

                              Thanks,
                              but removing <s:messages /> will not help because other messages which I want to display will not be shown for Invalid user name or Invalid password.

                              • 12. Re: problem in login.seam
                                panky_p Novice

                                Hi,
                                I am trying it now with little different way, I am making use of faces and my login page is not using any java code to render login page after delivering the page it will make use of authentication only on login button action but it still shows the same message as soon as page is delivered on browser and shows

                                INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
                                sourceId=null[severity=(WARN 1), summary=(Please log in first), detail=(Please log in first)]
                                

                                Why is it so?

                                • 13. Re: problem in login.seam
                                  panky_p Novice

                                  What will be the problem with

                                  <h:message for="" style="color: red"/>

                                  Why it is showing that message "Please log in first"

                                  • 14. Re: problem in login.seam
                                    panky_p Novice

                                    No clues?? :-(

                                    1 2 Previous Next