0

Toolbar button in grid is in Row with no Rows parent

asked 2010-11-12 11:20:04 +0800

dastultz gravatar image dastultz
797 8

Hello,

I have a routine where you click on a Toolbarbutton in a grid, the index of the row the tbb is in is found, then the corresponding element is returned from the backing list model. I works all over the place except for one rare, non-reproducible case with the same 2 or 3 users, not everyone else. I put in some debugging code. This method gets called after the normal routine fails:

StringBuilder debug = new StringBuilder("Trying to find user for room control: " + tbbAddToRoom + "\n");
// try again to find user based on component, we're trying to get information to help troubleshoot ticket #243
ListModel listModel = ...
Grid grid = ...
Object data = null;
Component rowComponent = null;
Component parent = tbbAddToRoom.getParent();
while ((rowComponent == null) && (parent != null)) {
	if (parent instanceof Row) {
		debug.append("Found Row: " + parent + "\n");
		rowComponent = parent;
		// to ensure it's loaded
		grid.renderRow((Row) rowComponent);
		int index = grid.getRows().getChildren().indexOf(rowComponent);
		debug.append("Index of row in rows: " + index + "\n");
		if (index == -1) {
			debug.append("Trying to find by row parent\n");
			Component rows = rowComponent.getParent();
			if (rows != null) {
				index = rows.getChildren().indexOf(rowComponent);
				debug.append("Index of row in row parent: " + index + "\n");
			} else {
				debug.append("Row has no Rows parent\n");
			}
		}
		if (index != -1) data = listModel.getElementAt(index);
	}
	parent = parent.getParent();
}
if (data == null) throw new IllegalStateException("Could not find user by room control:\n" + debug);

And here is the debug output:

java.lang.IllegalStateException: Could not find user by room control:
Trying to find user for room control: <Toolbarbutton z_gu_hfo2>
Found Row: <Row z_gu_gtn2>
Index of row in rows: -1
Trying to find by row parent
Row has no Rows parent

So it appears the tbb is in a Row, but the Row is not in a Rows. How can it be that a tbb is clicked and the row is not attached to a Rows parent? Is it possible grid.renderRow((Row) rowComponent) could mess up the hierarchy?

Thanks.

/Daryl

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-11-15 10:58:04 +0800

dastultz gravatar image dastultz
797 8

Interestingly, it sort of semi-failed this time:

Found user by alternate means:
Trying to find user for room control: <Toolbarbutton z_cq_7aq1>
Found Row: <Row z_cq_t6q1>
Index of row in rows: -1
Trying to find by row parent
Index of row in row parent: 2

So now the tbb is not a member of the rows of the grid I've got a final reference to, but it still seems to have a Rows as a parent.

/Daryl

link publish delete flag offensive edit

answered 2010-11-22 19:33:33 +0800

SimonPai gravatar image SimonPai
1696 1

Hi dastultz,

From your description it's hard to draw a conclusion at the first glance. One of my guess is that there is a timing where the Row is somehow detached from the Rows, but I could be wrong.

To work around, maybe you can try to use Row#setValue() or component attribute to keep the index information on the Row, so you don't need to count for the index from Rows?

Regards,
Simon

link publish delete flag offensive edit

answered 2010-11-29 10:36:34 +0800

dastultz gravatar image dastultz
797 8

That's an interesting idea, I'll give it a try.

Thanks.

/Daryl

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-11-12 11:20:04 +0800

Seen: 307 times

Last updated: Nov 29 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More