child page do not decorate untll it's been clicked in an outline based application [message #1007620] |
Wed, 06 February 2013 18:24 |
Boy D'Poy Messages: 67 Registered: October 2011 |
Member |
|
|
Let suppose that I have these two classes in an outline based application.
public class MyNodePage extends AbstractPageWithNodes {
...
private String id;
...
// @FormData get/setId ...
@Override
protected void execDecorateCell(final Cell cell) {
// some decoration code
}
...
}
public class MyTablePage extends AbstractPageWithTable<MyTablePage.Table> {
...
@Override
protected IPage execCreateChildPage(final ITableRow row) throws ProcessingException {
final MyNodePage childPage = new MyNodePage();
...
childPage.setId((String) row.getCell(this.getTable().getIDColumn()).getValue());
...
return childPage;
}
}
when running my application, everything runs fine and cool, except that I have to click the child node before I get the decoration portion of code being executed, otherwise, the node is labelled as the first column of the TablePage.
what dit I miss, and how ist it possible to get the children nodes automatically decorated once the parent node is expanded?
[System : scout 3.8.1]
thank you!
Once You Go Scout, You Never Come Out!
|
|
|
|
|
|
|
Summary Cell [message #1007940 is a reply to message #1007890] |
Fri, 08 February 2013 10:54 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
Thanks a lot for your example!
This is a (not so well documented) desired behavior:
When the nodes representing the pages are created in the main windows, a "virtual Page" is created. This virtual page is like a proxy. On click on this virtual page, the corresponding real child page is instantiated (meaning loaded and decorated).
You can influence the virtual page decoration: have a look at execCreateVirtualChildPage(ITableRow) in AbstractPageWithTable.
The virtual page mechanism was added some years ago, because we had performance problem (in case it is expensive to load the child page). I am not sure it is possible to bypass the mechanism.
I my opinion this is a misusage of the Virtual pages... I do not know what you do in your "MyNodePage" class and how setting the String Id coming from the IDColumn affects the IDColumn.
We have always managed to compute the virtual child page from the Table information (with a hidden summary column and/or with some special logic decorating the virtual page). Just after the user click on the Page, the virtual page is resolved (the real page is instantiated). Because the decoration of the virtual and the real page is the same, the user doesn't see the difference.
childPage.setId((String) row.getCell(this.getTable().getIDColumn()).getValue());
It will allow me to explain another mechanism:
When the TablePage loads its child pages, it creates a list of virtual pages. The cell used in the node tree to represent the child is derived from the "row summary cell".
A row summary cell is derived from the columns defined as summary. In your example, if I add the summary property to the NameColumn:
@Order(20.0)
public class NameColumn extends AbstractStringColumn {
@Override
protected String getConfiguredHeaderText() {
return TEXTS.get("Name0");
}
@Override
protected boolean getConfiguredSummary() {
return true;
}
}
I will get:
(Since I use execCreateChildPage and not execCreateVirtualChildPage, I still have the label change on click)
It is possible to define more than one column as summary column. I can set the summary == true on the IDColumn.
For the summary cell, the labels of the summary columns are collected and (there is a String concatenation with a space between the texts).
I get:
Something I often do is to add an additional hidden summary column:
With execDecorateCell() in the column, I can control the text.
@Order(1000.0)
public class SummaryColumn extends AbstractStringColumn {
@Override
protected boolean getConfiguredDisplayable() {
return false;
}
@Override
@ConfigOperation
@Order(40.0)
protected void execDecorateCell(Cell cell, ITableRow row) throws ProcessingException {
final StringBuilder sb = new StringBuilder();
sb.append('[');
sb.append(getIDColumn().getValue(row));
sb.append(']');
sb.append('[');
sb.append(getNameColumn().getValue(row));
sb.append(']');
sb.append('[');
sb.append(getNotesColumn().getValue(row));
sb.append(']');
cell.setText(sb.toString());
}
@Override
protected boolean getConfiguredSummary() {
return true;
}
}
I could also set an IconId on the cell.
Another approach could be to override getSummaryCell(row) in your column, but I am not sure if the Scout API encourage this. (There is no execComputeSummaryCell(row) method).
Side note: If you do it with the summary cells, I think that you can remove "getConfiguredTitle" and "execDecorateCell" from MyNodePage.
I think this post should be merged in the wiki at:
Table > Summary Cell
[Updated on: Fri, 08 February 2013 13:56] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03499 seconds