How to enable a button when filling a textfield with VAADIN
up vote
0
down vote
favorite
I work with Vaadin. I have a text field and a button. My button is initially disabled. When my text field is filled with valid data my button must activate. I can not activate my button. Could you help me ? Thank you
public static DynTextField createFromElement(Element elt, DynForm form)
if (elt.getNodeName().equals("param") && elt.getAttribute("type").equals("TEXT"))
DynTextField dtf = new DynTextField();
dtf.setForm(form);
if (elt.hasAttribute("texte"))
dtf.setCaption(elt.getAttribute("texte"));
dtf.nom = elt.getAttribute("nom");
if (elt.hasAttribute("FORMAT"))
dtf.setFormat(elt.getAttribute("FORMAT"));
dtf.setDescription(elt.getAttribute("description"));
dtf.setStyleName("param" + (elt.hasAttribute("class") ? elt.getAttribute("class") : ""));
return dtf;
else
return null;
private void setFormat(String attribute)
binder = new Binder<>();
binder.forField(this).withValidator(new RegexpValidator("Saisie obligatoire !!", attribute)).asRequired("Format Erroné").bind(No.getter(), No.setter());
//new Binder<>().forField(this).withValidator(new RegexpValidator(attribute, "Format Erroné")).asRequired();
// convenience empty getter and setter implementation for better readability
public static class No
public static <SOURCE, TARGET> ValueProvider<SOURCE, TARGET> getter()
return source -> null;
public static <BEAN, FIELDVALUE> Setter<BEAN, FIELDVALUE> setter()
return (bean, fieldValue) ->
//no op
;
The program that creates my button. This is where I would like to make my button active.
public DynButton(DynForm form, String as400PGMName, String parameterList)
super(VaadinIcons.CHECK);
this.as400PGMName = as400PGMName;
if (parameterList.length == 1 && parameterList[0].equals(""))
this.parameterList = new String ;
else
this.parameterList = parameterList;
this.form = form;
addClickListener(event ->
fireClickEvent(event);
);
addClickListener(this);
impl = new DynComponentImpl();
//boutton initially disable
this.setEnabled(isActif());
java vaadin
add a comment |
up vote
0
down vote
favorite
I work with Vaadin. I have a text field and a button. My button is initially disabled. When my text field is filled with valid data my button must activate. I can not activate my button. Could you help me ? Thank you
public static DynTextField createFromElement(Element elt, DynForm form)
if (elt.getNodeName().equals("param") && elt.getAttribute("type").equals("TEXT"))
DynTextField dtf = new DynTextField();
dtf.setForm(form);
if (elt.hasAttribute("texte"))
dtf.setCaption(elt.getAttribute("texte"));
dtf.nom = elt.getAttribute("nom");
if (elt.hasAttribute("FORMAT"))
dtf.setFormat(elt.getAttribute("FORMAT"));
dtf.setDescription(elt.getAttribute("description"));
dtf.setStyleName("param" + (elt.hasAttribute("class") ? elt.getAttribute("class") : ""));
return dtf;
else
return null;
private void setFormat(String attribute)
binder = new Binder<>();
binder.forField(this).withValidator(new RegexpValidator("Saisie obligatoire !!", attribute)).asRequired("Format Erroné").bind(No.getter(), No.setter());
//new Binder<>().forField(this).withValidator(new RegexpValidator(attribute, "Format Erroné")).asRequired();
// convenience empty getter and setter implementation for better readability
public static class No
public static <SOURCE, TARGET> ValueProvider<SOURCE, TARGET> getter()
return source -> null;
public static <BEAN, FIELDVALUE> Setter<BEAN, FIELDVALUE> setter()
return (bean, fieldValue) ->
//no op
;
The program that creates my button. This is where I would like to make my button active.
public DynButton(DynForm form, String as400PGMName, String parameterList)
super(VaadinIcons.CHECK);
this.as400PGMName = as400PGMName;
if (parameterList.length == 1 && parameterList[0].equals(""))
this.parameterList = new String ;
else
this.parameterList = parameterList;
this.form = form;
addClickListener(event ->
fireClickEvent(event);
);
addClickListener(this);
impl = new DynComponentImpl();
//boutton initially disable
this.setEnabled(isActif());
java vaadin
The first program that allows me to fill a valid field
– woodson
21 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I work with Vaadin. I have a text field and a button. My button is initially disabled. When my text field is filled with valid data my button must activate. I can not activate my button. Could you help me ? Thank you
public static DynTextField createFromElement(Element elt, DynForm form)
if (elt.getNodeName().equals("param") && elt.getAttribute("type").equals("TEXT"))
DynTextField dtf = new DynTextField();
dtf.setForm(form);
if (elt.hasAttribute("texte"))
dtf.setCaption(elt.getAttribute("texte"));
dtf.nom = elt.getAttribute("nom");
if (elt.hasAttribute("FORMAT"))
dtf.setFormat(elt.getAttribute("FORMAT"));
dtf.setDescription(elt.getAttribute("description"));
dtf.setStyleName("param" + (elt.hasAttribute("class") ? elt.getAttribute("class") : ""));
return dtf;
else
return null;
private void setFormat(String attribute)
binder = new Binder<>();
binder.forField(this).withValidator(new RegexpValidator("Saisie obligatoire !!", attribute)).asRequired("Format Erroné").bind(No.getter(), No.setter());
//new Binder<>().forField(this).withValidator(new RegexpValidator(attribute, "Format Erroné")).asRequired();
// convenience empty getter and setter implementation for better readability
public static class No
public static <SOURCE, TARGET> ValueProvider<SOURCE, TARGET> getter()
return source -> null;
public static <BEAN, FIELDVALUE> Setter<BEAN, FIELDVALUE> setter()
return (bean, fieldValue) ->
//no op
;
The program that creates my button. This is where I would like to make my button active.
public DynButton(DynForm form, String as400PGMName, String parameterList)
super(VaadinIcons.CHECK);
this.as400PGMName = as400PGMName;
if (parameterList.length == 1 && parameterList[0].equals(""))
this.parameterList = new String ;
else
this.parameterList = parameterList;
this.form = form;
addClickListener(event ->
fireClickEvent(event);
);
addClickListener(this);
impl = new DynComponentImpl();
//boutton initially disable
this.setEnabled(isActif());
java vaadin
I work with Vaadin. I have a text field and a button. My button is initially disabled. When my text field is filled with valid data my button must activate. I can not activate my button. Could you help me ? Thank you
public static DynTextField createFromElement(Element elt, DynForm form)
if (elt.getNodeName().equals("param") && elt.getAttribute("type").equals("TEXT"))
DynTextField dtf = new DynTextField();
dtf.setForm(form);
if (elt.hasAttribute("texte"))
dtf.setCaption(elt.getAttribute("texte"));
dtf.nom = elt.getAttribute("nom");
if (elt.hasAttribute("FORMAT"))
dtf.setFormat(elt.getAttribute("FORMAT"));
dtf.setDescription(elt.getAttribute("description"));
dtf.setStyleName("param" + (elt.hasAttribute("class") ? elt.getAttribute("class") : ""));
return dtf;
else
return null;
private void setFormat(String attribute)
binder = new Binder<>();
binder.forField(this).withValidator(new RegexpValidator("Saisie obligatoire !!", attribute)).asRequired("Format Erroné").bind(No.getter(), No.setter());
//new Binder<>().forField(this).withValidator(new RegexpValidator(attribute, "Format Erroné")).asRequired();
// convenience empty getter and setter implementation for better readability
public static class No
public static <SOURCE, TARGET> ValueProvider<SOURCE, TARGET> getter()
return source -> null;
public static <BEAN, FIELDVALUE> Setter<BEAN, FIELDVALUE> setter()
return (bean, fieldValue) ->
//no op
;
The program that creates my button. This is where I would like to make my button active.
public DynButton(DynForm form, String as400PGMName, String parameterList)
super(VaadinIcons.CHECK);
this.as400PGMName = as400PGMName;
if (parameterList.length == 1 && parameterList[0].equals(""))
this.parameterList = new String ;
else
this.parameterList = parameterList;
this.form = form;
addClickListener(event ->
fireClickEvent(event);
);
addClickListener(this);
impl = new DynComponentImpl();
//boutton initially disable
this.setEnabled(isActif());
java vaadin
java vaadin
asked 21 hours ago
woodson
12
12
The first program that allows me to fill a valid field
– woodson
21 hours ago
add a comment |
The first program that allows me to fill a valid field
– woodson
21 hours ago
The first program that allows me to fill a valid field
– woodson
21 hours ago
The first program that allows me to fill a valid field
– woodson
21 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
You can do it with a listener on either the text field or the binder
textField.addValueChangeListener(e ->
myButton.setEnabled(!e.getValue().equals("")));
or
binder.addStatusChangeListener(e ->
myButton.setEnabled(!e.hasValidationErrors()));
I did as you told me; it does not work. My button does not listen to my text fields. Here is my program : private DynTextField dtf1 = new DynTextField(); dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
1
@woodson It should work, but you have to specify the button which should be enabled/disabled when text is entered in the text fields.
– André Schild
20 hours ago
this.setEnabled (isActif ()); allows me to disable my button. Here is my isActive program: private boolean isActive () for (String param: parameterList) if (! getForm (). getParam (param) .isValid ()) return false; return true; I do not see how to implement it
– woodson
20 hours ago
So this had to work : dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
I tried this code it does not work. Someone could give me some advice: dtf1.addValueChangeListener(event -> if(event.getValue().isEmpty()) this.setEnabled(isActif()); else this.setEnabled(isActif()); );
– woodson
15 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
You can do it with a listener on either the text field or the binder
textField.addValueChangeListener(e ->
myButton.setEnabled(!e.getValue().equals("")));
or
binder.addStatusChangeListener(e ->
myButton.setEnabled(!e.hasValidationErrors()));
I did as you told me; it does not work. My button does not listen to my text fields. Here is my program : private DynTextField dtf1 = new DynTextField(); dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
1
@woodson It should work, but you have to specify the button which should be enabled/disabled when text is entered in the text fields.
– André Schild
20 hours ago
this.setEnabled (isActif ()); allows me to disable my button. Here is my isActive program: private boolean isActive () for (String param: parameterList) if (! getForm (). getParam (param) .isValid ()) return false; return true; I do not see how to implement it
– woodson
20 hours ago
So this had to work : dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
I tried this code it does not work. Someone could give me some advice: dtf1.addValueChangeListener(event -> if(event.getValue().isEmpty()) this.setEnabled(isActif()); else this.setEnabled(isActif()); );
– woodson
15 hours ago
add a comment |
up vote
4
down vote
You can do it with a listener on either the text field or the binder
textField.addValueChangeListener(e ->
myButton.setEnabled(!e.getValue().equals("")));
or
binder.addStatusChangeListener(e ->
myButton.setEnabled(!e.hasValidationErrors()));
I did as you told me; it does not work. My button does not listen to my text fields. Here is my program : private DynTextField dtf1 = new DynTextField(); dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
1
@woodson It should work, but you have to specify the button which should be enabled/disabled when text is entered in the text fields.
– André Schild
20 hours ago
this.setEnabled (isActif ()); allows me to disable my button. Here is my isActive program: private boolean isActive () for (String param: parameterList) if (! getForm (). getParam (param) .isValid ()) return false; return true; I do not see how to implement it
– woodson
20 hours ago
So this had to work : dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
I tried this code it does not work. Someone could give me some advice: dtf1.addValueChangeListener(event -> if(event.getValue().isEmpty()) this.setEnabled(isActif()); else this.setEnabled(isActif()); );
– woodson
15 hours ago
add a comment |
up vote
4
down vote
up vote
4
down vote
You can do it with a listener on either the text field or the binder
textField.addValueChangeListener(e ->
myButton.setEnabled(!e.getValue().equals("")));
or
binder.addStatusChangeListener(e ->
myButton.setEnabled(!e.hasValidationErrors()));
You can do it with a listener on either the text field or the binder
textField.addValueChangeListener(e ->
myButton.setEnabled(!e.getValue().equals("")));
or
binder.addStatusChangeListener(e ->
myButton.setEnabled(!e.hasValidationErrors()));
answered 20 hours ago
Tazavoo
598210
598210
I did as you told me; it does not work. My button does not listen to my text fields. Here is my program : private DynTextField dtf1 = new DynTextField(); dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
1
@woodson It should work, but you have to specify the button which should be enabled/disabled when text is entered in the text fields.
– André Schild
20 hours ago
this.setEnabled (isActif ()); allows me to disable my button. Here is my isActive program: private boolean isActive () for (String param: parameterList) if (! getForm (). getParam (param) .isValid ()) return false; return true; I do not see how to implement it
– woodson
20 hours ago
So this had to work : dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
I tried this code it does not work. Someone could give me some advice: dtf1.addValueChangeListener(event -> if(event.getValue().isEmpty()) this.setEnabled(isActif()); else this.setEnabled(isActif()); );
– woodson
15 hours ago
add a comment |
I did as you told me; it does not work. My button does not listen to my text fields. Here is my program : private DynTextField dtf1 = new DynTextField(); dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
1
@woodson It should work, but you have to specify the button which should be enabled/disabled when text is entered in the text fields.
– André Schild
20 hours ago
this.setEnabled (isActif ()); allows me to disable my button. Here is my isActive program: private boolean isActive () for (String param: parameterList) if (! getForm (). getParam (param) .isValid ()) return false; return true; I do not see how to implement it
– woodson
20 hours ago
So this had to work : dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
I tried this code it does not work. Someone could give me some advice: dtf1.addValueChangeListener(event -> if(event.getValue().isEmpty()) this.setEnabled(isActif()); else this.setEnabled(isActif()); );
– woodson
15 hours ago
I did as you told me; it does not work. My button does not listen to my text fields. Here is my program : private DynTextField dtf1 = new DynTextField(); dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
I did as you told me; it does not work. My button does not listen to my text fields. Here is my program : private DynTextField dtf1 = new DynTextField(); dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
1
1
@woodson It should work, but you have to specify the button which should be enabled/disabled when text is entered in the text fields.
– André Schild
20 hours ago
@woodson It should work, but you have to specify the button which should be enabled/disabled when text is entered in the text fields.
– André Schild
20 hours ago
this.setEnabled (isActif ()); allows me to disable my button. Here is my isActive program: private boolean isActive () for (String param: parameterList) if (! getForm (). getParam (param) .isValid ()) return false; return true; I do not see how to implement it
– woodson
20 hours ago
this.setEnabled (isActif ()); allows me to disable my button. Here is my isActive program: private boolean isActive () for (String param: parameterList) if (! getForm (). getParam (param) .isValid ()) return false; return true; I do not see how to implement it
– woodson
20 hours ago
So this had to work : dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
So this had to work : dtf1.addValueChangeListener(event -> this.setEnabled(isActif()));
– woodson
20 hours ago
I tried this code it does not work. Someone could give me some advice: dtf1.addValueChangeListener(event -> if(event.getValue().isEmpty()) this.setEnabled(isActif()); else this.setEnabled(isActif()); );
– woodson
15 hours ago
I tried this code it does not work. Someone could give me some advice: dtf1.addValueChangeListener(event -> if(event.getValue().isEmpty()) this.setEnabled(isActif()); else this.setEnabled(isActif()); );
– woodson
15 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204337%2fhow-to-enable-a-button-when-filling-a-textfield-with-vaadin%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
The first program that allows me to fill a valid field
– woodson
21 hours ago