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
- window
- vaadin
- Python
- 보조정렬
- GIT
- mybatis
- Spring
- R
- SQL
- IntelliJ
- MSSQL
- plugin
- mapreduce
- Android
- Express
- Java
- Kotlin
- Eclipse
- hadoop
- table
- SSL
- tomcat
- react
- xPlatform
- NPM
- SPC
- es6
- 공정능력
- JavaScript
- Sqoop
Archives
- Today
- Total
DBILITY
vaadin Layout 수동 교체? 본문
반응형
최상위에 VerticalLayout에 로그인 관련 Component가 존재하고,
로그인을 하면 최상위 레이아웃의 모든 Component를 clear(?) 한 후
다른 Component를 배치하는걸 해봤다. 그냥.. 아무런 이유는 없다.
package com.vseminar.vaadin_seminar2;
import java.util.regex.Pattern;
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.navigator.Navigator;
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.Notification;
import com.vaadin.ui.Notification.Type;
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.Constants;
/**
* 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.
*/
/**
*
* Description
*
*
* @author @user
*
* @version 1.0.0
* @date 2018. 6. 16.
*=======================================================================
* Date Name Revision History
*=======================================================================
* 2018. 6. 16. hyperrookie@gmail.com Creation
*=======================================================================
*/
@SuppressWarnings("serial")
@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;
Navigator navigator;
@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.addBlurListener(e->{
if( email.getValue().length() > 0 && !Pattern.matches(Constants.REGEX_EMAIL, email.getValue())) {
Notification.show(Constants.MSG_FORMAT_EMAIL, Type.WARNING_MESSAGE);
email.focus();
logger.debug("{}", email.getValue());
}
});
email.setValue("user@userc.com");
final PasswordField password = new PasswordField("Password");
password.setIcon(FontAwesome.LOCK);
password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
password.addBlurListener(e->{
if (password.getValue().length() > 0 && !Pattern.matches(Constants.REGEX_PASSWORD, password.getValue())) {
Notification.show(Constants.MSG_FORMAT_PASSWORD, Type.WARNING_MESSAGE);
password.focus();
}
});
password.setValue("1234Tabc!");
final Button signon = new Button("signon");
signon.setStyleName(ValoTheme.BUTTON_PRIMARY);
signon.addClickListener(e->{
if ( !Pattern.matches(Constants.REGEX_EMAIL, email.getValue()) || !Pattern.matches(Constants.REGEX_PASSWORD, password.getValue()) ) {
logger.debug("{} / {}", email.getValue(),password.getValue());
message.setValue(Constants.MSG_FORMAT_ALL);
message.setVisible(true);
return;
}
layout.removeAllComponents();
final VerticalLayout dashBoard = new VerticalLayout();
dashBoard.setSpacing(true);
Label topTitle = new Label("DashBoard");
topTitle.setSizeUndefined();
dashBoard.addComponent(topTitle);
dashBoard.setComponentAlignment(topTitle, Alignment.TOP_LEFT);
layout.addComponent(dashBoard);
});
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 fieldGroup 사용하기 (0) | 2018.06.28 |
---|---|
크롬 브라우저 캐시 불능 처리 (0) | 2018.06.27 |
vaadin Navigator 실습 (0) | 2018.06.18 |
vaadin Polling 실습 (0) | 2018.06.17 |
vaadin session 실습 (0) | 2018.06.17 |
Comments