[
https://issues.apache.org/jira/browse/TAP5-135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12641078#action_12641078
]
amannhardt edited comment on TAP5-135 at 10/20/08 10:37 AM:
----------------------------------------------------------------
We are affected when using a workaround for default sorting. Basically we
update the grid sort constraints if none are set. That works with Tapestry
5.0.14, but fails in 5.0.15 with a Nullpointer because initialization changed.
Used is now "dataModel" (instead of "model" previously) which is initialized on
setupRender - too late for the example below.
public class Index
{
private BeanModel<TestRow> _testModel;
@Inject
private BeanModelSource _beanModelSource;
@Inject
private Messages _messages;
@Component(id="testGrid")
private Grid _grid;
private List<TestRow> _testSource = new ArrayList<TestRow>();
{
_testSource.add(new TestRow("c"));
_testSource.add(new TestRow("a"));
_testSource.add(new TestRow("b"));
}
public static class TestRow {
private String _testCol;
public TestRow(String s) {
_testCol = s;
}
public String getTestCol() {
return _testCol;
}
public void setTestCol(String testCol) {
_testCol = testCol;
}
}
public void setupRender() {
_testModel = _beanModelSource.create(TestRow.class, false, _messages);
if ( _grid.getSortModel().getSortContraints().isEmpty() ) {
_grid.getSortModel().updateSort("testCol");
}
}
public List<TestRow> getTestSource() {
return _testSource;
}
public void setTestSource(List<TestRow> testSource) {
this._testSource = testSource;
}
public BeanModel<TestRow> getTestModel() {
return _testModel;
}
}
public class Index
{
private BeanModel<TestRow> _testModel;
@Inject
private BeanModelSource _beanModelSource;
@Inject
private Messages _messages;
@Component(id="testGrid")
private Grid _grid;
private List<TestRow> _testSource = new ArrayList<TestRow>();
{
_testSource.add(new TestRow("c"));
_testSource.add(new TestRow("a"));
_testSource.add(new TestRow("b"));
}
public static class TestRow {
private String _testCol;
public TestRow(String s) {
_testCol = s;
}
public String getTestCol() {
return _testCol;
}
public void setTestCol(String testCol) {
_testCol = testCol;
}
}
public void setupRender() {
_testModel = _beanModelSource.create(TestRow.class, false, _messages);
if ( _grid.getSortModel().getSortContraints().isEmpty() ) {
_grid.getSortModel().updateSort("testCol");
}
}
public List<TestRow> getTestSource() {
return _testSource;
}
public void setTestSource(List<TestRow> testSource) {
this._testSource = testSource;
}
public BeanModel<TestRow> getTestModel() {
return _testModel;
}
}
-------
[...]
<t:grid
t:id="testGrid"
t:source="testSource"
t:model="testModel"/>
[...]
was (Author: amannhardt):
We are affected when using a workaround for default sorting. Basically we
update the grid sort constraints if none are set. That works with Tapestry
5.0.14, but fails in 5.0.15 with a Nullpointer because initialization changed.
Used is now "dataModel" (instead of "model" previously) which is initialized on
setupRender - too late for the example below.
here is an example:
public class Index
{
private BeanModel<TestRow> _testModel;
@Inject
private BeanModelSource _beanModelSource;
@Inject
private Messages _messages;
@Component(id="testGrid")
private Grid _grid;
private List<TestRow> _testSource = new ArrayList<TestRow>();
{
_testSource.add(new TestRow("c"));
_testSource.add(new TestRow("a"));
_testSource.add(new TestRow("b"));
}
public static class TestRow {
private String _testCol;
public TestRow(String s) {
_testCol = s;
}
public String getTestCol() {
return _testCol;
}
public void setTestCol(String testCol) {
_testCol = testCol;
}
}
public void setupRender() {
_testModel = _beanModelSource.create(TestRow.class, false, _messages);
if ( _grid.getSortModel().getSortContraints().isEmpty() ) {
_grid.getSortModel().updateSort("testCol");
}
}
public List<TestRow> getTestSource() {
return _testSource;
}
public void setTestSource(List<TestRow> testSource) {
this._testSource = testSource;
}
public BeanModel<TestRow> getTestModel() {
return _testModel;
}
}
public class Index
{
private BeanModel<TestRow> _testModel;
@Inject
private BeanModelSource _beanModelSource;
@Inject
private Messages _messages;
@Component(id="testGrid")
private Grid _grid;
private List<TestRow> _testSource = new ArrayList<TestRow>();
{
_testSource.add(new TestRow("c"));
_testSource.add(new TestRow("a"));
_testSource.add(new TestRow("b"));
}
public static class TestRow {
private String _testCol;
public TestRow(String s) {
_testCol = s;
}
public String getTestCol() {
return _testCol;
}
public void setTestCol(String testCol) {
_testCol = testCol;
}
}
public void setupRender() {
_testModel = _beanModelSource.create(TestRow.class, false, _messages);
if ( _grid.getSortModel().getSortContraints().isEmpty() ) {
_grid.getSortModel().updateSort("testCol");
}
}
public List<TestRow> getTestSource() {
return _testSource;
}
public void setTestSource(List<TestRow> testSource) {
this._testSource = testSource;
}
public BeanModel<TestRow> getTestModel() {
return _testModel;
}
}
-------
[...]
<t:grid
t:id="testGrid"
t:source="testSource"
t:model="testModel"/>
[...]
> Grid.getSortContraints NPE when sortColumnId != null
> ----------------------------------------------------
>
> Key: TAP5-135
> URL: https://issues.apache.org/jira/browse/TAP5-135
> Project: Tapestry 5
> Issue Type: Bug
> Affects Versions: 5.0.15
> Reporter: Andy Huhn
>
> After I click the header of a grid column to sort by that header, I receive a
> NPE from Grid.getSortContraints.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]