I have created a simpile component, just a button on the screen, and I am trying to figure out how to run that component. I can run it directly so I modified the java class that was created when I created my product, and I still can not run it.
Component code generated with Visual Designer
/**
* The constructor should first build the main layout, set the
* composition root and then do any custom initialization.
*
* The constructor will not be automatically regenerated by the
* visual editor.
*/
public TestComp() {
buildMainLayout();
setCompositionRoot(mainLayout);
// TODO add user code here
}
@AutoGenerated
private AbsoluteLayout buildMainLayout() {
// common part: create layout
mainLayout = new AbsoluteLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
// top-level component properties
setWidth("100.0%");
setHeight("100.0%");
// button_1
button_1 = new Button();
button_1.setCaption("Button");
button_1.setImmediate(false);
button_1.setWidth("-1px");
button_1.setHeight("-1px");
mainLayout.addComponent(button_1, "top:20.0px;left:20.0px;");
return mainLayout;
}
}
Code generate when project create and then modified by me.
package com.example.testapp;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@SuppressWarnings(“serial”)
@Theme(“testapp”)
public class TestappUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = TestappUI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
TestComp test = new TestComp();
layout.addComponent(test);
//
// Button button = new Button(“Click Me”);
// button.addClickListener(new Button.ClickListener() {
// public void buttonClick(ClickEvent event) {
// layout.addComponent(new Label(“Thank you for clicking”));
// }
// });
// layout.addComponent(button);
}
}
Any help you can give me would be appreicated.