tags:

views:

171

answers:

1

I am developing a website as part of my final year project and I want to display a message which confirms that an email has been sent.

I know how to display custom error messages on a form i.e. You cannot go any further until the following errors are fixed : login name not known!

I want to display a message which will say: your email has been sent! after I send an email. I have been told that I should display this message through the flash.

I am unsure on how to do this, any help would be greatly appreciated.

+2  A: 

The simplest thing to do would be to show a conditional message on the page displayed when the message was sent, like:

<span t:type="If" t:test="messageSent">Your message was sent.</span>

Page class snippet:

@Persist(PersistenceConstants.FLASH)
private boolean messageSent;


public boolean isMessageSent() {
    return this.messageSent;
}

@OnEvent(EventConstants.SUCCESS)
void onSendMessage() {
    ...
    this.messageSent = true;
}

If you have other places in your code where you'd like to display messages, or if you'd like to do some fancy AJAX, creating a messages component to add to your layout might be an option.

Henning