Add even on Button made on Composite UI

I am very much new with Vaadin. I have made buttons on Composite UI and now I want to call another compositeUI (loginUI) on the button click. What should I do and where should I write the click event. I tried but failed. Below are my code

public class Logon extends CustomComponent {
@AutoGenerated
private AbsoluteLayout mainLayout;

@AutoGenerated
private Label welcome;

@AutoGenerated
private HorizontalLayout horizontalLayout_2;

@AutoGenerated
private Button registerButton;

@AutoGenerated
private Button loginButton;

/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
final static Logger logger = Logger.getLogger(Logon.class);

/**
 * 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 Logon() {
    buildMainLayout();
    setCompositionRoot(mainLayout);
    // TODO add user code here
    logger.info(resources.org.tu.strike4cash.LogonConf.buttonClickA);
    LoginUI loginUI = new LoginUI();
}

@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%");
    
    // horizontalLayout_2
    horizontalLayout_2 = buildHorizontalLayout_2();
    mainLayout.addComponent(horizontalLayout_2, "top:90.0px;right:348.0px;bottom:334.0px;left:120.0px;");
    
    // welcome
    welcome = new Label();
    welcome.setCaption("Welcome to Strike4Cash");
    welcome.setImmediate(false);
    welcome.setWidth("-1px");
    welcome.setHeight("100.0%");
    welcome.setValue("Earn cash in simple click");
    mainLayout.addComponent(welcome, "top:60.0px;bottom:374.0px;left:431.0px;");
    
    return mainLayout;
}

@AutoGenerated
private HorizontalLayout buildHorizontalLayout_2() {
    // common part: create layout
    horizontalLayout_2 = new HorizontalLayout();
    horizontalLayout_2.setImmediate(false);
    horizontalLayout_2.setWidth("100.0%");
    horizontalLayout_2.setHeight("100.0%");
    horizontalLayout_2.setMargin(false);
    
    // loginButton
    loginButton = new Button();
    loginButton.setCaption("Login");
    loginButton.setImmediate(true);
    loginButton.setWidth("100.0%");
    loginButton.setHeight("-1px");
    horizontalLayout_2.addComponent(loginButton);
    horizontalLayout_2.setExpandRatio(loginButton, 1.0f);
    
    // registerButton
    registerButton = new Button();
    registerButton.setCaption("Register");
    registerButton.setImmediate(true);
    registerButton.setWidth("100.0%");
    registerButton.setHeight("-1px");
    horizontalLayout_2.addComponent(registerButton);
    horizontalLayout_2.setExpandRatio(registerButton, 1.0f);
    
    return horizontalLayout_2;
}

}

Are you using the old and deprecated Visual Designer with Eclipse? I strongly recommend Vaadin Designer instead (commercial product).

Anyways using Navigator is a good way to implement navigation. In your UI class init method.

@Override protected void init(VaadinRequest vaadinRequest) { // .... Navigator navigator = new Navigator(this, this); navigator.addView("someview", SomeView.class); navigator.addView("anotherview", AnotherView.class); setNavigator(navigator); if ("".equals(navigator.getState())) { navigator.navigateTo("someview"); } } Using navigator requires your views to implement com.navigator.View interface.

Yes I am using old deprecated Visual Designer, I have applied for Student Key but no one ever replied to me.

Did you try to use Navigator?

Sorry to hear no one answered your application. The instructions for non-commercial license key applications has been clarified to explain that due to high amount of requests, applications must be done by the teacher / faculty member.

I copied the latest instructions from /pro-tools and they are the following

  • Application email must be sent from the official domain provided by the institute
  • Application for an educational institute needs to be done by an employee of the institute (not students). If you are a student, you should ask a professor or an employee at the educational institute to request the licenses
  • Please provide a brief description of the project

Hi Hayry,

I have tried using the Navigtor from all the resource I got on internet but not helping me yet. Below attched are 3 java files.
TestAppUI is Main Class which Calls Logon Composite UI when application run. On click of button inside Logon.java I want to open LoginUI which is another Composite UI. You can see I have added some code. But not working .

For second part:
I am actually not a student. I am a Java Developer working with IBM in India, I have encounter Vaadin 3 days ago and I find it quite useful and very efficient. So I have decided myself to learn it and work only only on Vaadin. (nothing to do with IBM). But I cannot pay that much amount for yearly. It is too high for me. That is the reason I am trying to learn from the resources I got for Free fro you guys.
25810.java (3.52 KB)
25811.java (991 Bytes)
25812.java (1.04 KB)

Well if at first Navigator seems too difficult to use, you can always call

        loginButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().setContent(new LoginUI());
            }
        });

Wow, This was easy but haven’t found on Google. Problem Solved. Thanks for the Help Hayry… As I said I am new to Vaadin. I might will disturb you all Pros. :slight_smile:

It was great help!