Vaadin submit action for custom made forms

486 Views Asked by At

In my vaadin application, I'm trying to create a login form. If I use default login form provided by vaadin framework. I can set the posting of the user entered data via .setAction() method to spring security.

    private LoginForm login = new LoginForm(); 



public Login(){
    addClassName("login-view");
    setSizeFull();
    setAlignItems(Alignment.CENTER); 


    setJustifyContentMode(JustifyContentMode.CENTER);

    **login.setAction("login");**  

    add(new H1("Vaadin CRM"), login);
}

However, I don't want to use this login form, rather use the custom designed form created by horizontal layout or whatever. Problem is, any of these components or layouts don't have this .setAction() method where I can submit the data post to "login" location. I also couldn't find solution or source about this on their website. Because of this, spring security doesn't retrieve these username password data. How can I overcome this problem? Thanks in advance.

1

There are 1 best solutions below

0
On

You'll need a client-side <form> element in order to have a form action. If you look at how the vaadin-login-form is implemented, you can see the <form> element here: https://github.com/vaadin/vaadin-login/blob/master/src/vaadin-login-form.html#L23-L36

Probably the easiest way to have a custom login form that submits a form action would be to create a similar custom web component as vaadin-login-form and bind it to the server using a PolymerTemplate. If you want to stick to server-side Java, you could also try if a server side Element with the tag form does the trick.