New add-on: LoginForm

[b]
What you can read below is beginner’s guide to setting up an addon,
which can help if you have never done it before.


IMPORTANT: There is no problem with the Loginform addon. It is not the addon’s responsibility
to set the widgetset. The widgetset error arises from the lack of knowledge on the user’s part.

[/b]

This might be useful for other beginners. Solution for the widgetset error:


Widgetset ‘com.vaadin.DefaultWidgetSet’ does not contain implementation for com.ejt.vaadin.loginform.DefaultVerticalLoginForm."…


Setting up the loginform addon step-by-step

  1. add the following to ivx.xml, after which ivy successfully fetched loginform

<dependency org="org.vaadin.addons" name="loginform" rev="0.5.1" /> 2. add some example code to the UI’s
init
method:[code]
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);

    DefaultVerticalLoginForm loginForm = new DefaultVerticalLoginForm();
    loginForm.addLoginListener(new LoginListener() {
        @Override
        public void onLogin(LoginEvent event) {
            System.err.println(
                    "Logged in with user name " + event.getUserName() +
                            " and password of length " + event.getPassword().length());

        }
    });
    
    layout.addComponent(loginForm);
    
}

[/code]3. click on the
Compile Widgetset
icon:


4. go to
WebContent/VAADIN/widgetsets
, here you will see a directory starting with you namespace, in my case the name of the directory is was
com.example.vaadintest.widgetset.VaadintestWidgetset
. Add this name as a
@Widgetset
annotation to the UI class. @Widgetset("com.example.vaadintest.widgetset.VaadintestWidgetset") public class VaadintestUI extends UI { 5. Select
Project → clean,
wait for recompilation
6. Go to the
Servers
tab and click
Restart the server in debug mode

It’s not related to this plugin, you’re not using a correctly compiled widgetset.

Yes, I know. Sorry for not making it clear. I have edited the post. Also, I am not asking for help, just describing how to solve the widgetset error for others if they are new to using addons.

Version 0.4 works perfect, but with 0.5.1 I get an ivy failure: unresolved dependency: org.vaadin.addons#loginform;0.5.1: not found.

Can you fix this?

The version is published and should. The maven server is managed by Vaadin and I cannot do anything about it. Maybe it’s a temporary thing.

I’ve got the same problem. My workaround was to download the jar manually and put it in my local Maven repository. Still, I hope that the Vaadin guys can fix this quickly.

I have asked the Vaadin team about this.

They say that the maven server is OK and that 0.5.1 can be downloaded by maven. It might by a problem if you try to get it from a maven repository other than the official one for add-ons.

Hi,

I make a simple application with your sample of “DefaultVerticalLoginForm”, and it works on my pc on Chrome and Safari, but I want used my web application on my Ipad. And in my Ipad, the login and the password are really saved but not the autofill.
I want launch the autofill login and password automatically.

Have you got a solution for me?

Thanks.

I don’t have any mobile Apple devices. If you can contribute a solution, that would be great. It’s also possible that auto-fill is not supported by the browser.

Hello, one minor question:
I do not manage to get this addon working if I use an input prompt on the password field. If I do this, the autofill will be pasted as input prompt and clicking login will give an empty value for the password field.

Is there a fix/workaround for this? Or is the use of an input prompt for the password field not possible?

Using an input prompt for the password field does not seem to be possible

Yes, I can download it directly from the official repository, thanks. To clarify, my setup contains a local Maven Nexus acting as a proxy. For some reason the Nexus can not access the official repository anymore. Maybe I need to update it.

Anyway, now that I am using it, I was wondering, is there a way to access the fields in the default layouts? I would like to remove the entered text when the web app navigates back to the login view after the user has logged out.

I have not provided accessors on purpose, otherwise people will extract the components from the LoginForm instance and add them to the UI - and that will not work. You can subclass the default form and save the text fields for later use.

Based on your feedback, I just added a “clear()” method for the next release that will clear both text fields.

Great, thank you very much!

Please can you help with the 4 errors below.

The method getPassword() is undefined for the type LoginForm.LoginEvent

The method getUserName() is undefined for the type LoginForm.LoginEvent

The method onLogin(LoginForm.LoginEvent) of type new LoginForm.LoginListener(){} must override or implement a supertype method

The type new LoginForm.LoginListener(){} must implement the inherited abstract method LoginForm.LoginListener.onLogin(LoginForm.LoginEvent)

New to Java and Vaadin

package com.na7kr.yt_100;

import javax.servlet.annotation.WebServlet;
import com.ejt.vaadin.loginform.DefaultVerticalLoginForm;
import com.ejt.vaadin.loginform.LoginForm.LoginListener;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
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.LoginForm.LoginEvent;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
@Theme("yt_100")
@Widgetset("com.na7kr.yt_100.widgetset.Yt_100Widgetset")
public class Yt_100UI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = Yt_100UI.class, widgetset = "com.na7kr.yt_100.widgetset.Yt_100Widgetset")
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
DefaultVerticalLoginForm loginForm = new DefaultVerticalLoginForm();
loginForm.addLoginListener(new LoginListener() {
@Override
public void onLogin(LoginEvent event) {
System.err.println("Logged in with user name " + event.getUserName() + " and password of length "
+ event.getPassword().length());
}
});
layout.addComponent(loginForm);
}
}

Also is there a replacment for LoginForm.LoginEvent is deprecated ?

You import import com.vaadin.ui.LoginForm that is the deprecated class in the Vaadin libraries. You have to import com.ejt.vaadin.loginform.LoginForm instead.

This is my first time installing and trying to use a Vaadin add-on. It is not going well:

Widgetset 'com.vaadin.DefaultWidgetSet' does not contain implementation for com.ejt.vaadin.loginform.DefaultVerticalLoginForm. Check its component connector's @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to [u] add-on instructions [/u]. This is displayed in the browser window, not the console. And this is after using the DefaultVerticalLoginForm code on the add-on page without making any changes to it. I don’t even understand what it wants me to do, let alone how to do it. Please help?

This problem has nothing to do with this particular add-on. You’re not serving the compiled widget set to the browser, but the standard widget set.