use of io.jmix.ui.component.ValuePicker in project jmix-docs by Haulmont.
the class ValuePickerScreen method onInit.
// end::inject-valuePickerClearAction[]
// tag::onInit-start[]
@Subscribe
protected void onInit(InitEvent event) {
// end::onInit-start[]
// tag::base-action-value-picker[]
ValuePicker valueField = uiComponents.create(ValuePicker.NAME);
valueField.addAction(new BaseAction("hello") {
@Override
public String getCaption() {
return null;
}
@Override
public String getDescription() {
return messageBundle.getMessage("helloDescription");
}
@Override
public String getIcon() {
return JmixIcon.HANDSHAKE_O.source();
}
@Override
public void actionPerform(Component component) {
notifications.create().withCaption("Hello!").withType(Notifications.NotificationType.TRAY).show();
}
});
valueField.addAction(new BaseAction("goodbye").withCaption(null).withDescription(messageBundle.getMessage("goodbyeDescription")).withIcon(JmixIcon.HAND_PAPER_O.source()).withHandler(e -> notifications.create().withCaption("Goodbye!").withType(Notifications.NotificationType.TRAY).show()));
vBox.add(valueField);
// end::base-action-value-picker[]
loginValuePicker.addAction(new BaseAction("showValue").withHandler(actionPerformedEvent -> {
String value = loginValuePicker.getValue();
notifications.create().withCaption(value != null ? value : "No value").show();
}).withDescription("Show Value").withIcon(JmixIcon.EYE.source()));
// tag::add-clear-action1[]
loginValuePicker.addAction(actions.create(ValueClearAction.ID));
// end::add-clear-action1[]
// tag::onInit-end[]
}
Aggregations