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

    problem in login.seam

    panky_p Novice

      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()
          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()
            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.



              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


                  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

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

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

                    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):


                      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


                        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.

                          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")

                          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()
                             "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

                              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

                                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