Hi, I’m new at this forum, I tried to search about my problem but was in vain so far.
I’m student and I’m trying to develop a web-app to train my skills, I grab the “FormAdvancedLayoutExample” from the vaadin sampler and I’m trying to put in my code,
but i’m having some troubles to set this right.
This is my Field Factory Class, first when I tried to open the window I got this error message: “Caused by: java.lang.ClassCastException: com.vaadin.ui.DateField cannot be cast to com.vaadin.ui.PopupDateField”.
Ok. I commented the lines with the PopupDateField and the window shows up, but something very odd is happening, the data fields are showing up in the window, I don’t know from where it comes.
public class PlanoIntegradoFieldFactory extends DefaultFieldFactory{
final ComboBox countries = new ComboBox("Country");
private static final String COMMON_FIELD_WIDTH = "12em";
public PlanoIntegradoFieldFactory() {
countries.setWidth("100%");
countries.setContainerDataSource(ExampleUtil.getISO3166Container());
countries.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME);
countries.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG);
countries.setFilteringMode(ComboBox.FILTERINGMODE_STARTSWITH);
}
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
Field f;
if ("idPlano".equals(propertyId)) {
return countries;
} else {
// Use the super class to create a suitable field base on the
// property type.
f = super.createField(item, propertyId, uiContext);
}
if ("nmPlano".equals(propertyId)) {
TextField tf = (TextField) f;
String nullRepresentation = "";
tf.setRequired(true);
tf.setRequiredError("Nome do plano integrado");
tf.setWidth(COMMON_FIELD_WIDTH);
tf.setNullRepresentation(nullRepresentation );
tf.addValidator(new StringLengthValidator(
"Nome do plano precisa ter no mínimo 3-25 caracteres", 3, 25, false));
} else if ("dtIniPlano".equals(propertyId)) {
//PopupDateField dt = (PopupDateField) f;
//dt.setRequired(true);
//dt.setRequiredError("Data inicial do plano integrado");
//dt.setWidth(COMMON_FIELD_WIDTH);
} else if ("dtFimPlano".equals(propertyId)) {
//PopupDateField dt = (PopupDateField) f;
//dt.setRequired(true);
//dt.setRequiredError("Data final do plano integrado");
//dt.setWidth(COMMON_FIELD_WIDTH);
}
return f;
}
}
This is the image from my web app,
http://imageshack.us/f/268/semttulosdq.png/
And another question, how can I cut off this countries combo box from the code?
I tied to take off but this return statement I don’t know what to do with that, I just want my fields.
final ComboBox countries = new ComboBox("Country");
private static final String COMMON_FIELD_WIDTH = "12em";
public PlanoIntegradoFieldFactory() {
countries.setWidth("100%");
countries.setContainerDataSource(ExampleUtil.getISO3166Container());
countries.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME);
countries.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG);
countries.setFilteringMode(ComboBox.FILTERINGMODE_STARTSWITH);
}
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
Field f;
if ("idPlano".equals(propertyId)) {
return countries;
} else {
// Use the super class to create a suitable field base on the
// property type.
f = super.createField(item, propertyId, uiContext);
}
Sorry about my English and thanks All.