in the login behavior, set the failed redirect to go back to itself with the failed=1 querystring variable.
for example if my login page is "login.php" I set the failed redirect in the login behavior as:
login.php?failed=1
then use the code form my previous reply to show the message.