- Components
- Notification
Notification
An alert that pins to the corner of the screen when triggered by JavaScript. It can be set to disappear after a certain period of time, or to stay put until the user clicks on it.
It works as a replacement for the
<h:messages
tag, but can also be used to show arbitrary messages generated client side via the Widget API.
Notifications also support an optional icon
to be displayed with the message, and an optional closable
attribute that will override the default for the notification component. To support this server side, TornadoFaces
comes with a NotificationMessage
class that extends FacesMessage.
<t:notification id="msgs" widgetVar="msgs"/>
<a href="#" class="button alert" onclick="TW('msgs').show('Ouch!', 'An error occured', 'ERROR')">Error message</a>
<a href="#" class="button warning" onclick="TW('msgs').show('Danger!', 'Be warned', 'WARN')">Warning message</a>
<a href="#" class="button success" onclick="TW('msgs').show('Success!', 'Victory!', 'SUCCESS')">Success message</a>
<h:form>
<t:commandButton value="Server info" action="#{controller.alert}" render=":msgs"/>
</h:form>
public class alert() {
FacesContext.getCurrentInstance().addMessage(null, new NotificationMessage(
"Success!",
"A successfull server generated message",
"http://url/to/image.png").closable(false));
}
An alert that pins to the corner of the screen when triggered by JavaScript. It can be set to disappear after a certain period of time, or to stay put until the user clicks on it.
Info
Tag name | notification |
---|---|
Component type | io.tornadofaces.component.Notification |
Renderer type | io.tornadofaces.component.NotificationRenderer |
Attributes
Name | Description | Required |
---|---|---|
timeout | The timeout in milliseconds for the notification to stay visible. Set to 0 for a sticky notification. | false |
position | The position of the notification. Valid values are "top-right", "bottom-right", "bottom-left" and "top-left". Default "top-right". | false |
closable | Non closable notifications cannot be closed by the user once the are visible, but will dissapear when the timeout is reached, or never if timeout is 0. Default true. | false |
widgetVar | Widget variable name, accessible via TW('widgetVar') and TornadoFaces.widgets.widgetVar. | false |
rendered | Should this component be rendered? | false |
Client Side API
Widget: TornadoFaces.widget.Notification
Method | Params | Return type | Description |
---|---|---|---|
show(summary) | summary: The title of the notification | void | Show a notification with just a title |
show(summary, detail) | summary: The title, detail: The body of the notification | void | Show a notification with a title and body |
show(summary, detail, severity) | summary: The title, detail: The body, severity: The severity of the notification | void | Show a notification with a title, body and the given severity. Valid severity levels are INFO, WARN, ERROR. |
show(summary, detail, severity, image) | summary: The title, detail: The body, severity: The severity, image: The icon of the notification | void | Show a notification with a title, body, severity and the given image. |
show(message) | message: A configuration object containing one or more of summary, detail and severity | void | Show a notification with the given configuration. |