Skip to content
Snippets Groups Projects
Commit ec84019b authored by Timo Jeremy Pinzauti's avatar Timo Jeremy Pinzauti
Browse files

Letzte Änderungen am ContactView. Leider klappt der Validator noch nicht....

Letzte Änderungen am ContactView. Leider klappt der Validator noch nicht. Scheint an lokalen Problemen zu liegen.
parent b2279806
Branches ContactView
No related tags found
No related merge requests found
......@@ -10,7 +10,6 @@ import com.vaadin.ui.Panel;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import org.s4s.services.util.EmailValidator;
/**
* Created by Max-Desktop on 16.05.2017.
......@@ -26,7 +25,6 @@ public class ContactView extends TemplateView{
setMargin(true);
final TextField tfEMail = new TextField("E-Mail");
tfEMail.addValidator(new EmailValidator());
final TextField tfBetreff = new TextField("Betreff");
final TextArea taNachricht = new TextArea("Ihr Anliegen");
final Button bSenden = new Button("Senden", FontAwesome.SEND);
......@@ -42,7 +40,7 @@ public class ContactView extends TemplateView{
this.setComponentAlignment(pKontakt, Alignment.MIDDLE_CENTER);
pKontakt.setContent(vLayout);
super.setUpFooterAndHeader(vLayout);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.s4s.services.util;
import com.vaadin.data.Validator;
/**
*
* @author synot
*/
public class EmailValidator implements Validator {
/**
* Tests if the given value is valid
* @param value the value to test
*/
public boolean isValid(Object value) {
try {
validate(value);
} catch (Validator.InvalidValueException ive) {
return false;
}
return true;
}
/**
* Validates
* @param value the value to test
*/
public void validate(Object value) throws Validator.InvalidValueException {
// Here value is a String containing what *should* be an e-mail address
if (value instanceof String) {
String email = (String)value;
// Match the email string against a (simplistic) regular expression matching e-mail addresses
if (!email.matches("^[_\\w\\.\\-]+@[\\w\\.-]+\\.[a-z]{2,6}$"))
throw new Validator.InvalidValueException("The e-mail address provided is not valid!");
}
}
}
///*
// * To change this license header, choose License Headers in Project Properties.
// * To change this template file, choose Tools | Templates
// * and open the template in the editor.
// */
//package org.s4s.services.util;
//
//import com.vaadin.data.Validator;
//
///**
// *
// * @author synot
// */
//public class EmailValidator implements Validator {
// /**
// * Tests if the given value is valid
// * @param value the value to test
// */
// public boolean isValid(Object value) {
// try {
// validate(value);
// } catch (Validator.InvalidValueException ive) {
// return false;
// }
// return true;
// }
//
// /**
// * Validates
// * @param value the value to test
// */
// public void validate(Object value) throws Validator.InvalidValueException {
// // Here value is a String containing what *should* be an e-mail address
// if (value instanceof String) {
// String email = (String)value;
// // Match the email string against a (simplistic) regular expression matching e-mail addresses
// if (!email.matches("^[_\\w\\.\\-]+@[\\w\\.-]+\\.[a-z]{2,6}$"))
// throw new Validator.InvalidValueException("The e-mail address provided is not valid!");
// }
// }
//}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment