use of com.hack23.cia.web.impl.ui.application.views.pageclicklistener.CommitFormWrapperClickListener in project cia by Hack23.
the class FormFactoryImpl method addRequestInputFormFields.
@Override
public <T extends Serializable> void addRequestInputFormFields(final FormLayout panelContent, final T item, final Class<T> beanType, final List<String> displayProperties, final String buttonLabel, final ClickListener buttonListener) {
final BeanValidationBinder<T> binder = new BeanValidationBinder<>(beanType);
binder.setBean(item);
binder.setReadOnly(true);
for (final String property : displayProperties) {
final AbstractField buildAndBind;
if (property.contains(HIDDEN_FIELD_NAME)) {
buildAndBind = new PasswordField();
binder.bind(buildAndBind, property);
} else {
buildAndBind = new TextField();
binder.bind(buildAndBind, property);
}
buildAndBind.setCaption(property);
buildAndBind.setId(MessageFormat.format("{0}.{1}", buttonLabel, property));
buildAndBind.setReadOnly(false);
buildAndBind.setWidth(ContentSize.HALF_SIZE);
panelContent.addComponent(buildAndBind);
}
final VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setWidth("50%");
final Button button = new Button(buttonLabel, new CommitFormWrapperClickListener(binder, buttonListener));
button.setId(buttonLabel);
button.setWidth("25%");
button.setIcon(VaadinIcons.BULLSEYE);
button.setEnabled(false);
binder.addStatusChangeListener(event -> {
button.setEnabled(event.getBinder().isValid());
});
verticalLayout.addComponent(button);
verticalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);
panelContent.addComponent(verticalLayout);
}
Aggregations