-
1. Re: Simple question - How to change Welcome, <username> after log-in (not in header)
valatharv Mar 4, 2009 6:59 PM (in response to valatharv)Adding to above mail, please suggest how can I track
org.jboss.seam.loginSuccessful=Welcome, #0 in "messages_en.properties" -
2. Re: Simple question - How to change Welcome, <username> after log-in (not in header)
kragoth Mar 5, 2009 1:59 AM (in response to valatharv)To override the message:
1. Create a properties file eg security_messages.properties
2. In this file put org.jboss.seam.loginSuccessful= (to override the seam message) and then put in your own message.
egorg.jboss.seam.loginSuccessful= my.custom.welcome.message=Welcome #0 #1
3. Load this properties file in your app, this requires you to modify components.xml
eg (you will need to fix the directory based on where you put this in your app etc<core:resource-loader> <core:bundle-names> <value>bundles/security_messages</value> </core:bundle-names> </core:resource-loader>
Last but not least. In your authenticate method you need to add your custom message when the user successfully logs in so...
public boolean authenticate() { ....(logic to check if valid user if (validUser) { FacesMessagesUtils.addInfoFromBundle( "my.custom.welcome.message", loggedInUser.getFirstName(), loggedInUser.getLastName()); return true; }
-
3. Re: Simple question - How to change Welcome, <username> after log-in (not in header)
valatharv Mar 5, 2009 4:49 AM (in response to valatharv)Thanks for the response Tim, we will try to implement the changes, for the time being as we needed to display the first & last name so I changed "org.jboss.seam.loginSuccessful=Welcome, #0"
to
org.jboss.seam.loginSuccessful=Welcome, #{getUsers.users.firstName} #{getUsers.users.lastName}
where getUsers is a simple bean which returns users object. -
4. Re: Simple question - How to change Welcome, <username> after log-in (not in header)
aank1 Aug 27, 2009 9:43 AM (in response to valatharv)I am not sure these details matter, but I am using Seam 2.1.1 and Richfaces 3.2.2.
I have tried Tim's solution but it hasn't quite worked for me: all the messages.properties file were ignored.
So in the end, after trying more solutions, the one that worked for me is:
- in the Authenticator class - 'authenticate' method I added:
facesMessages.addFromResourceBundle("my.custom.welcome.message", loggedUser.getContactUser().getUserFirstName(), loggedUser.getContactUser().getUserLastName());
- in messages_x.properties I added the tags:
org.jboss.seam.loginSuccessful=
my.custom.welcome.message=Bienvenue, \#0 \#1 -
5. Re: Simple question - How to change Welcome, <username> after log-in (not in header)
kragoth Aug 27, 2009 9:54 AM (in response to valatharv)Unless I'm missing something you are using the solution I said, but using the default location for you .properties file.
If your properties files are being ignored then the chances are that you are not loading them correctly. (Wrong path/spelling etc)
Anyways, I'm glad it's working for you! :D