You are on page 1of 3

package 

com.example.test;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.Notification;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

/**
 * This UI is the application entry point. A UI may either represent a browser w
indow 
 * (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 inte
nded to be 
 * overridden to add component to the user interface and initialize non-
component functionality.
 */
@SpringUI(path = "/")
@Theme("mytheme")
public class MyUI extends UI {
  private Button button;
  private TextField name;
  private Label label;
  private Link link;
  private VerticalLayout layout;
  @Override
  protected void init(VaadinRequest request) {
    // TODO Auto-generated method stub
    
  }

    public VerticalLayout getLayout() {
      VerticalLayout layout = new VerticalLayout();
      layout.addComponents(name, button, link);
        return layout;
    }

    public void setLayout(VerticalLayout layout) {
      setContent(layout);
      
    }
    
    public Link getLink() {
      Link link = new Link("Click here to Play",
        new ExternalResource("http://play.fresco.me"));

        return link;
    }
    public void setLink(){
      link.setTargetName("_blank");

    }
    
    public Label getLabel() {
        return label;
    }
    
    public Button getButton() {
      Button button = new Button("Click Me");
        return button;
    }

    public void setButton(){
      button.addClickListener(clickEvent ->
    Notification.show("Click on thid button"));

    }

    public TextField getName() {
      TextField name = new TextField("Type your name here");
        return name;
    }
    public void setName(){
      name.setValue("Enter value");
      name.addValueChangeListener(event ->
        Notification.show("Value is: " + event.getValue()));
    }
     @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true
)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}

You might also like