TL;DR Vaadin PasswordField
is a simple TextField
. The input is hidden just in client-side, in server-side is transmitted in clear text.
Although you can use getConvertedValue()
and setConvertedValue(Object value)
for getting/setting the value in your own type. Note that you have to set the setConverter(Converter<T,?> converter)
before using it.
Here you have an example of how to use properly the conversation: Creating your own converter for String - MyType conversion
FULL EXPLANATION
Vaadin TextField
, PasswordField
and TextArea
are all children of AbstractField<String>
.

In detail:
java.lang.Object
|_ com.vaadin.server.AbstractClientConnector
|_ com.vaadin.ui.AbstractComponent
|_ com.vaadin.ui.AbstractField<java.lang.String>
|_ com.vaadin.ui.AbstractTextField
PasswordField
works with String
because of its parents, otherwise it should have implemented AbstractField<char[]>
.
In addition in the PasswordField
section from Vaadin Docs says explicitly:
You should note that the PasswordField
hides the input only from "over the shoulder" visual observation. Unless the server connection is encrypted with a secure connection, such as HTTPS, the input is transmitted in clear text and may be intercepted by anyone with low-level access to the network. Also phishing attacks that intercept the input in the browser may be possible by exploiting JavaScript execution security holes in the browser.
Although AbstractField<T>
has getConvertedValue()
and setConvertedValue(Object value)
which allow to get/set the value in the Object
you prefer. Note that before using it you need to set setConverter(Converter<T,?> converter)
.
Here you have an example of how to use properly the conversation: Creating your own converter for String - MyType conversion
In short from the example:
Name
is a simple POJO with firstName
and lastName
fields and their getter/setter.
Converter class
public class StringToNameConverter implements Converter<String, Name> {
public Name convertToModel(String text, Locale locale) {
String[] parts = text.split(" ");
return new Name(parts[0], parts[1]);
}
public String convertToPresentation(Name name, Locale locale)
throws ConversionException {
return name.getFirstName() + " " + name.getLastName();
}
public Class<Name> getModelType() {
return Name.class;
}
public Class<String> getPresentationType() {
return String.class;
}
}
Main class
Name name = new Name("Rudolph", "Reindeer");
final TextField textField = new TextField("Name");
textField.setConverter(new StringToNameConverter());
textField.setConvertedValue(name);
addComponent(textField);
addComponent(new Button("Submit value", new ClickListener() {
public void buttonClick(ClickEvent event) {
Name name = (Name) textField.getConvertedValue();
}
}));
Full source