Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in Grid #17

Open
guttormvik opened this issue Jan 5, 2016 · 0 comments
Open

Doesn't work in Grid #17

guttormvik opened this issue Jan 5, 2016 · 0 comments

Comments

@guttormvik
Copy link

The attached example gives a client-side classcast exception.

If I were to guess, I'd say that the problem is that the Grid editor expects the connector to be an AbstractFieldConnector, while UploadField uses AbstractComponentConnector or something?

Seems that there are two separate problems then:

  • UploadField doesn't fully behave like a "field"
  • Grid should not insist on its editor components to be Fields
package com.example.test_easyuploads;

import javax.servlet.annotation.WebServlet;

import org.vaadin.easyuploads.UploadField;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Grid;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
@Theme("test_easyuploads")
public class Test_easyuploadsUI extends UI {

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = Test_easyuploadsUI.class, widgetset = "com.example.test_easyuploads.widgetset.Test_easyuploadsWidgetset")
    public static class Servlet extends VaadinServlet {
    }

    public static class Row {

        String text;
        byte[] data;

        public String getText() {
            return text;
        }
        public void setText(String text) {
            this.text = text;
        }
        public byte[] getData() {
            return data;
        }
        public void setData(byte[] data) {
            this.data = data;
        }

    }

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        final BeanItemContainer<Row> container = new BeanItemContainer<>(Row.class);

        container.addBean(new Row());
        container.addBean(new Row());

        Grid grid = new Grid(container);
        grid.setEditorEnabled(true);

        final UploadField gridUploadField = new UploadField();
        gridUploadField.setFileDeletesAllowed(false);
        gridUploadField.setDisplayUpload(false);
        grid.getColumn("data").setEditorField(gridUploadField);

        layout.addComponent(grid);

    }

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant