io.imunity.vaadin.endpoint.common.plugins.attributes.components.SingleStringFieldBinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unity-server-vaadin-endpoint-common Show documentation
Show all versions of unity-server-vaadin-endpoint-common Show documentation
Common Vaadin endpoint components
The newest version!
/*
* Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
* See LICENCE.txt file for licensing information.
*/
package io.imunity.vaadin.endpoint.common.plugins.attributes.components;
import com.vaadin.flow.component.HasValue;
import com.vaadin.flow.data.binder.Binder;
import io.imunity.vaadin.elements.StringBindingValue;
import pl.edu.icm.unity.base.message.MessageSource;
import java.util.function.Supplier;
public class SingleStringFieldBinder extends Binder
{
private final MessageSource msg;
public SingleStringFieldBinder(MessageSource msg)
{
super(StringBindingValue.class);
this.msg = msg;
}
public BindingBuilder forField(HasValue, String> field, boolean required)
{
BindingBuilder bindingBuilder = forField(field);
if (required)
bindingBuilder.asRequired(msg.getMessage("fieldRequired"));
return bindingBuilder;
}
public void ensureValidityCatched(Supplier errorProvider) throws T
{
if (!isValid())
{
validate();
throw errorProvider.get();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy