-
1. Re: problem in login.seam
swd847 Oct 8, 2007 8:21 AM (in response to panky_p)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 Oct 8, 2007 9:03 AM (in response to panky_p)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 Oct 8, 2007 10:40 AM (in response to panky_p)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 Oct 8, 2007 11:38 AM (in response to panky_p)If you don't want the messages use identity.authenticate instead of identity.login.
-
5. Re: problem in login.seam
panky_p Oct 9, 2007 2:11 AM (in response to panky_p)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 Oct 9, 2007 6:02 AM (in response to panky_p)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 Oct 10, 2007 12:15 AM (in response to panky_p)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 Oct 10, 2007 2:30 AM (in response to panky_p)Yes Shane,
I did try on messages.properties by addingorg.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
swd847 Oct 10, 2007 2:39 AM (in response to panky_p)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
swd847 Oct 10, 2007 2:49 AM (in response to panky_p)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 Oct 10, 2007 3:42 AM (in response to panky_p)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 Oct 10, 2007 10:43 AM (in response to panky_p)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 showsINFO [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 Oct 10, 2007 10:58 AM (in response to panky_p)What will be the problem with
<h:message for="" style="color: red"/>
Why it is showing that message "Please log in first" -