Skip to content

try0/wicket-toastr

Repository files navigation

wicket-toastr

Build Status codecov Quality Gate Status Maven Central Javadocs

Apache Wicket utilities for using 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

Usage

Maven

Wicket10

<dependency>
    <groupId>jp.try0.wicket</groupId>
    <artifactId>wicket-toastr-core</artifactId>
    <version>3.0.0</version>
</dependency>

Wicket9

<dependency>
    <groupId>jp.try0.wicket</groupId>
    <artifactId>wicket-toastr-core</artifactId>
    <version>2.0.0</version>
</dependency>

Wicket8

<dependency>
    <groupId>jp.try0.wicket</groupId>
    <artifactId>wicket-toastr-core</artifactId>
    <version>1.0.2</version>
</dependency>

Initialize Settings

You can set default values, in the application initialize process(Application#init).

ToastrSettings.createInitializer(this)
.setAutoAppendBehavior(true)
.setMessageFilter(filter)
.setToastrBehaviorFactory(factory)
.initialize();

Display toast using ToastrBehavior

add ToastrBehavior to any of the components on the page

add(new ToastrBehavior());

or set true to setAutoAppendBehavior on initialize settings

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.

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

Others

With title

Toast.create(toastLevel, message)
.withTitle(title)
.show(target);

With options

Overrides global options.

Toast.create(toastLevel, message)
.withToastOptions(options)
.show(target);