Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Problem with sizing of components
Hi,
I've got a problem with not displayed components when using a form. I've created a custom component with the gui builder, containing the openlayers addon.
Now I want to access the fields in the component with the Formbinder addon.
If I display the custom Component with out the formBinder everything looks fine - It takes all the place which is there, and the map takes all the place which the tow other components do not need.
If I put it in the form binder its not displaying the custom component.
What do I do wrong here?
Regrads
Daniel
The custom component:
package com.example.vaadin_test;
import org.vaadin.vol.OpenLayersMap;
import org.vaadin.vol.OpenStreetMapLayer;
import com.vaadin.annotations.AutoGenerated;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
public class CustomForm extends CustomComponent
{
@AutoGenerated
private VerticalLayout mainLayout;
@AutoGenerated
private TextField textField;
@AutoGenerated
private PopupDateField dateField;
@AutoGenerated
private OpenLayersMap positionField;
/**
* 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 CustomForm()
{
buildMainLayout();
setCompositionRoot(mainLayout);
// TODO add user code here
positionField.addLayer(new OpenStreetMapLayer());
}
@AutoGenerated
private VerticalLayout buildMainLayout()
{
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("100.0%");
setHeight("100.0%");
// positionField
positionField = new OpenLayersMap();
positionField.setImmediate(false);
positionField.setWidth("100.0%");
positionField.setHeight("100.0%");
mainLayout.addComponent(positionField);
mainLayout.setExpandRatio(positionField, 1.0f);
// dateField
dateField = new PopupDateField();
dateField.setImmediate(false);
dateField.setWidth("-1px");
dateField.setHeight("-1px");
dateField.setInvalidAllowed(false);
mainLayout.addComponent(dateField);
// textField
textField = new TextField();
textField.setImmediate(false);
textField.setWidth("-1px");
textField.setHeight("-1px");
textField.setSecret(false);
mainLayout.addComponent(textField);
return mainLayout;
}
}
The application with out the formbinder - works, but no binding
package com.example.vaadin_test;
import org.vaadin.addon.formbinder.ViewBoundForm;
import com.vaadin.Application;
import com.vaadin.data.util.BeanItem;
import com.vaadin.ui.Button;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Window;
public class Vaadin_testApplication extends Application
{
@Override
public void init()
{
final Window mainWindow = new Window("Vaadin_test Application");
Button button = new Button("Show pojo state");
button.addListener(new Button.ClickListener()
{
public void buttonClick(ClickEvent event)
{
mainWindow.showNotification("Pojo state: " + myPojo);
}
});
VerticalLayout layout = new VerticalLayout();
layout.addComponent(customForm);
layout.addComponent(button);
layout.setExpandRatio(customForm, 1.00f);
layout.setExpandRatio(button, 0.00f);
layout.setHeight("100%");
mainWindow.setContent(layout);
setMainWindow(mainWindow);
}
}
The application with the formBinder, does not display the content of the customComponent
package com.example.vaadin_test;
import org.vaadin.addon.formbinder.ViewBoundForm;
import com.vaadin.Application;
import com.vaadin.data.util.BeanItem;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Vaadin_testApplication extends Application
{
@Override
public void init()
{
final Window mainWindow = new Window("Vaadin_test Application");
final MyPojo myPojo = new MyPojo();
CustomForm customForm = new CustomForm();
myPojo.setPosition("Bla");
ViewBoundForm form = new ViewBoundForm(customForm);
form.setSizeFull();
form.setCaption("MyCustomForm");
form.setItemDataSource(new BeanItem<MyPojo>(myPojo));
Button button = new Button("Show pojo state");
button.addListener(new Button.ClickListener()
{
public void buttonClick(ClickEvent event)
{
mainWindow.showNotification("Pojo state: " + myPojo);
}
});
VerticalLayout layout = new VerticalLayout();
layout.addComponent(form);
layout.addComponent(button);
layout.setExpandRatio(form, 1.00f);
layout.setExpandRatio(button, 0.00f);
layout.setHeight("100%");
mainWindow.setContent(layout);
setMainWindow(mainWindow);
}
}