Skip to content

try0/wicket-iziToast

Repository files navigation

wicket-iziToast

Apache Wicket utilities for using iziToast. wicket-iziToast converts the feedback message to JavaScript to display the toast.

Build Status Maven Central

Version

Version Wicket iziToast
3.0.0 10.x 1.4.0
2.1.0 9.x 1.4.0
1.1.0 8.x 1.4.0

Demo

Deployed wicket-izitoast-samples module.

Usage

Examples

Add wicket-izitoast-core dependency.
Wicket 10.x

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

Wicket 9.x

<dependency>
    <groupId>jp.try0.wicket</groupId>
    <artifactId>wicket-izitoast-core</artifactId>
    <version>2.1.0</version>
</dependency>

Wicket 8.x

<dependency>
    <groupId>jp.try0.wicket</groupId>
    <artifactId>wicket-izitoast-core</artifactId>
    <version>1.1.0</version>
</dependency>

Initialize Settings

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

IziToastSetting
.createInitializer(this)
.setAutoAppendBehavior(true)
.setGlobalOption(option) // default iziToast option. apply in client-side (execute iziToast.settings(option))
.setGlobalEachLevelOptions(perLevelOptions) // default option per levels. apply in server-side.
.setToastMessageCombiner(combiner) // combiner that combine same level feedback messages.
.initialize();

Properties

AutoAppendBehavior

if true add IziToastBehavior to page automatically.

GlobalOption

Default toast option. Execute iziToast.settings(option) on the client-side and apply the default option.

GlobalEachLevelOptions

Default toast option per levels.

ToastOption defaultInfoOption = new ToastOption();
// TODO set option values

EachLevelToastOptions options = EachLevelToastOptions.builder()
        .setInfoOption(defaultInfoOption)
        .get();

// TODO setGlobalEachLevelOptions(options)

Option priority level Default option per levels (GlobalEachLevelOptions) > Default option (GlobalOption)

ToastMessageCombiner

Combiner that combines messages for each toast level.

ToastMessageCombiner combiner = new ToastMessageCombiner();
combiner.setPrefix("・");

// TODO setToastMessageCombiner(combiner)

If execute this Java code.

error("message1");
error("message2");

Messages are combined and displayed in one toast.

errors

Display toast

add IziToastBehavior to page. (If you set setAutoAppendBehavior to true when initializing settings, no need this code.)

add(new IziToastBehavior());

IziToastBehavior converts feedback messages to JavaScript for displaying toast.

Success toast

  • org.apache.wicket.Component#success(Serializable)
  • org.apache.wicket.Session#success(Serializable)

success

Information toast

  • org.apache.wicket.Component#info(Serializable)
  • org.apache.wicket.Session#info(Serializable)

info

Warning toast

  • org.apache.wicket.Component#warn(Serializable)
  • org.apache.wicket.Session#warn(Serializable)

warn

Error toast

  • org.apache.wicket.Component#error(Serializable)
  • org.apache.wicket.Session#error(Serializable)
  • org.apache.wicket.Component#fatal(Serializable)
  • org.apache.wicket.Session#fatal(Serializable)

error

Display toast manually

In this case, need instance of class that implemented IHeaderResponse or AjaxRequestTarget.

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