Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Sqoop
- Spring
- GIT
- 공정능력
- JavaScript
- Kotlin
- Python
- react
- SPC
- Java
- hadoop
- plugin
- vaadin
- mapreduce
- window
- Express
- Eclipse
- NPM
- table
- 보조정렬
- MSSQL
- SQL
- Android
- mybatis
- xPlatform
- es6
- IntelliJ
- R
- tomcat
- SSL
Archives
- Today
- Total
DBILITY
vaadin field validation 실습 본문
반응형
그냥 책을 보지 않고 해 봤다.
7.6.5로 버전을 내렸고, 나름 시간을 많이 보냈는데, vaadin의 연동방식을 익히는 중이랄까...
갑자기 4GL IDE에서 작업하는 느낌이다. DCEVM 또는 JRebel 없이 vaadin작업은 힘들 것 같다.
Designer license를 구입하고 나면 타이핑하는 양이 많이 줄겠지?
package com.vseminar.vaadin_seminar2;
import javax.servlet.annotation.WebServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
import com.vaadin.data.validator.EmailValidator;
import com.vaadin.data.validator.NullValidator;
import com.vaadin.data.validator.StringLengthValidator;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
import com.vseminar.vaadin_seminar2.util.PasswordValidator;
/**
* This UI is the application entry point. A UI may either represent a browser window
* (or tab) or some part of a html page where a Vaadin application is embedded.
* <p>
* The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be
* overridden to add component to the user interface and initialize non-component functionality.
*/
@Theme("vseminar")
@Widgetset("com.vseminar.vaadin_seminar2.VSeminarWidgetset")
public class VSeminarUI extends UI {
private static final Logger logger = LoggerFactory.getLogger(VSeminarUI.class);
private Label message;
@Override
protected void init(VaadinRequest vaadinRequest) {
logger.debug("vaadinRequest ----------> {}", vaadinRequest);
final VerticalLayout layout = new VerticalLayout();
final VerticalLayout loginPanel = new VerticalLayout();
loginPanel.setSizeUndefined();
loginPanel.setSpacing(true);
Label top = new Label("예쁜누나들은 어서오세요~<br />너는 아니다....",ContentMode.HTML);
top.addStyleName(ValoTheme.LABEL_H4);
top.addStyleName(ValoTheme.LABEL_COLORED);
loginPanel.addComponent(top);
message = new Label();
message.setVisible(false);
message.setSizeFull();
message.setStyleName(ValoTheme.LABEL_H4);
message.setStyleName(ValoTheme.LABEL_FAILURE);
loginPanel.addComponent(message);
final HorizontalLayout loginFileds = new HorizontalLayout();
loginFileds.setSizeUndefined();
loginFileds.setSpacing(true);
final TextField email = new TextField("Email");
email.setIcon(FontAwesome.USER);
email.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
email.addValidator(new EmailValidator("이메일형식을 확인해 누나~"));
email.addBlurListener(e->{
if( email.isValid() )
email.setValidationVisible(false);
else
email.setValidationVisible(true);
});
final PasswordField password = new PasswordField("Password");
password.setIcon(FontAwesome.LOCK);
password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
//password.addValidator(new StringLengthValidator("비번을 넣어야 열려라 참깨지롱~",8,50,false));
password.addValidator(new PasswordValidator("비번 좀 제대로 넣어 누나~"));
password.addBlurListener(e->{
if(password.isValid())
password.setValidationVisible(false);
else
password.setValidationVisible(true);
logger.debug("{}",password.isValid());
});
final Button signon = new Button("signon");
signon.setStyleName(ValoTheme.BUTTON_PRIMARY);
signon.addClickListener(e->{
if ( !email.isValid() || !password.isValid() ) {
logger.debug("{} / {}", email.getValue(),password.getValue());
message.setValue("우째 이럴까?");
message.setVisible(true);
return;
}
message.setVisible(false);
logger.debug(UI.getCurrent().getPage().getWindowName());
});
loginFileds.addComponents(email,password,signon);
loginFileds.setComponentAlignment(signon, Alignment.BOTTOM_LEFT);
loginPanel.addComponent(loginFileds);
layout.addComponent(loginPanel);
layout.setMargin(true);
layout.setSpacing(true);
layout.setSizeFull();
layout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
setContent(layout);
}
@WebServlet(urlPatterns = "/*", name = "VSeminarUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = VSeminarUI.class, productionMode = false)
public static class VSeminarUIServlet extends VaadinServlet {
}
}
반응형
'front-end & ui > vaadin legacy' 카테고리의 다른 글
vaadin layout 실습 (0) | 2018.06.16 |
---|---|
vaadin field validation 실습2 (0) | 2018.06.16 |
vaadin password validator (0) | 2018.06.15 |
vaadin 기초 정리 (0) | 2018.06.14 |
vaadin loginScreen 만들기 실습 (0) | 2018.06.11 |
Comments