An open API service indexing awesome lists of open source software.

https://github.com/try0/wicket-toastr

Apache Wicket utilities for using toastr.
https://github.com/try0/wicket-toastr

display-toast feedback-message java toast-component toastr wicket

Last synced: 3 months ago
JSON representation

Apache Wicket utilities for using toastr.

Awesome Lists containing this project

README

          

# wicket-toastr

[![Build Status](https://travis-ci.org/try0/wicket-toastr.svg?branch=develop)](https://travis-ci.org/try0/wicket-toastr)
[![codecov](https://codecov.io/gh/try0/wicket-toastr/branch/develop/graph/badge.svg)](https://codecov.io/gh/try0/wicket-toastr)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=try0_wicket-toastr&metric=alert_status)](https://sonarcloud.io/dashboard?id=try0_wicket-toastr)
[![Maven Central](https://img.shields.io/maven-central/v/jp.try0.wicket/wicket-toastr-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22jp.try0.wicket%22%20AND%20a:%22wicket-toastr-core%22)
[![Javadocs](https://www.javadoc.io/badge/jp.try0.wicket/wicket-toastr-core.svg?color=lightgrey)](https://www.javadoc.io/doc/jp.try0.wicket/wicket-toastr-core)

[Apache Wicket](https://wicket.apache.org/) utilities for using [toastr](https://codeseven.github.io/toastr/) which is a library of a simple javascript toast notification.
Just add behavior to the component, and you can display toast.
This behavior uses a wicket feedback message system.
Also, you can display toast manually without using a feedback message.

## Version
| |toastr |wicket |
|--:|--:|--:|
|3.0.0 |2.1.4 |10.x |
|2.0.0 |2.1.4 |9.x |
|1.0.2 |2.1.4 |8.x |

## Demo
Deployed wicket-toastr-samples module.
[demo](https://try0.jp/app/wicket-toastr-samples/)

## Usage

### Maven

Wicket10
```xml

jp.try0.wicket
wicket-toastr-core
3.0.0

```

Wicket9
```xml

jp.try0.wicket
wicket-toastr-core
2.0.0

```

Wicket8
```xml

jp.try0.wicket
wicket-toastr-core
1.0.2

```

### Initialize Settings
You can set default values, in the application initialize process(Application#init).
```java
ToastrSettings.createInitializer(this)
.setAutoAppendBehavior(true)
.setMessageFilter(filter)
.setToastrBehaviorFactory(factory)
.initialize();
```

### Display toast using ToastrBehavior

add ToastrBehavior to any of the components on the page
```java
add(new ToastrBehavior());
```
or set true to setAutoAppendBehavior on initialize settings
```java
ToastrSettings.createInitializer(this)
.setAutoAppendBehavior(true)
```

Component#success(Serializable), Session#success(Serializable)
⇒ success toast
toast_success

Component#info(Serializable), Session#info(Serializable)
⇒ info toast
toast_info

Component#warn(Serializable), Session#warn(Serializable)
⇒ warn toast
toast_warn

Component#error(Serializable), Session#error(SerializableSerializable)
Component#fatal(Serializable), Session#fatal(Serializable)
⇒ error toast
toast_error

### Display toast manually
In this case, it needs an instance of the class that implemented IHeaderResponse or AjaxRequestTarget.

```java
Toast.create(toastLevel, message)
.show(target);
```

### Others
#### With title
```java
Toast.create(toastLevel, message)
.withTitle(title)
.show(target);
```

#### With options
Overrides global options.
```java
Toast.create(toastLevel, message)
.withToastOptions(options)
.show(target);
```