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

When creating a RowRenderer with a factory, the control is not editable #18

Open
benshoe opened this issue Sep 18, 2017 · 3 comments
Open

Comments

@benshoe
Copy link
Contributor

benshoe commented Sep 18, 2017

Example:

RowRenderer<SomeClass> rr = new RowRenderer(SomeClass.class);
rr.column(BigDecimal.class, "property").factory(row -> {
Text<BigDecimal> ctrl = new Text<>(BigDecimal.class);
ctrl.bind().to(row, "property");
return ctrl;
}
).editable();

Without the 'editable()' method, the control is shown in read-only mode.

@benshoe
Copy link
Contributor Author

benshoe commented Feb 4, 2018

Hi, would this be a valid unit test for this bug?

public class RowRendererTest {

public class TestObject {

	BigDecimal m_property;

	public BigDecimal getProperty() {
		return m_property;
	}

	public void setProperty(BigDecimal property) {
		m_property = property;
	}
}

@Test
public void testEditableWithFactory() {
	RowRenderer<TestObject> rr = new RowRenderer<>(TestObject.class);
	rr.column(BigDecimal.class, "property").factory(row -> {
			Text2<BigDecimal> ctrl = new Text2<>(BigDecimal.class);
			ctrl.bind().to(row, "property");
			return ctrl;
		}
	).editable();

	ColumnDef<TestObject, ?> column = rr.getColumn(0);
	Assert.assertTrue("Column is editable", column.isEditable());

	rr.column(BigDecimal.class, "property").factory(row -> {
			Text2<BigDecimal> ctrl = new Text2<>(BigDecimal.class);
			ctrl.bind().to(row, "property");
			return ctrl;
		}
	);

	column = rr.getColumn(1);
	Assert.assertTrue("Column is also editable", column.isEditable());
}

}

@fjalvingh
Copy link
Owner

No, the second part is incorrect. You would have to validate that, after a render, the control that was rendered was editable. In this case you're just checking that the variable inside the column definition has been set - both your checks are the same.

You can either create a Selenium test (not that difficult, there is lots of infra) or make a test calling renderRow() of the RowRenderer. You would then get, inside the ColumnContainer, a call to add that control that was created. You can add a check for that.

@benshoe
Copy link
Contributor Author

benshoe commented Feb 18, 2018

I have created a pull request for this issue.

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

No branches or pull requests

2 participants