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

ArrayIndexOutOfBoundException in Spreadsheet.handleRowSizes when using a ComponentFactory #669

Open
edler-san opened this issue Jul 12, 2018 · 0 comments

Comments

@edler-san
Copy link

edler-san commented Jul 12, 2018

Vaadin version 8.4.5, Spreadsheet 2.1.0.alpha1

Minimal example to reproduce - just click the button.

package foo.bar;

import javax.servlet.annotation.WebServlet;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;

import com.vaadin.addon.spreadsheet.Spreadsheet;
import com.vaadin.addon.spreadsheet.SpreadsheetComponentFactory;
import com.vaadin.annotations.Theme;

import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@Theme("mytheme")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();
		Spreadsheet sheet = new Spreadsheet(6, 6);
		sheet.setSpreadsheetComponentFactory(getFactory());
        
		Button b = new Button("New entry");
		b.addClickListener(e -> addRow(sheet));

		layout.addComponent(b);
		layout.addComponent(sheet);
		setContent(layout);

    }

    private SpreadsheetComponentFactory getFactory() {
    	SpreadsheetComponentFactory f = new SpreadsheetComponentFactory() {
			
			@Override
			public void onCustomEditorDisplayed(Cell cell, int rowIndex, int columnIndex, Spreadsheet spreadsheet, Sheet sheet,
					Component customEditor) {
			}
			
			@Override
			public Component getCustomEditorForCell(Cell cell, int rowIndex, int columnIndex, Spreadsheet spreadsheet,
					Sheet sheet) {
				return null;
			}
			
			@Override
			public Component getCustomComponentForCell(Cell cell, int rowIndex, int columnIndex, Spreadsheet spreadsheet,
					Sheet sheet) {
				if((columnIndex==1))
					return new ComboBox();
				else
					return null;
			}
		};
		return f;
	}

	private void addRow(Spreadsheet sheet) {
		int rows = sheet.getRows();
		sheet.shiftRows(1, rows, 1);
		sheet.setMaxRows(rows + 1);
	}

	@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}

Possibly similar cause as #459 but at a different place in the code.

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