0

Aftercompose and InsertBefore

asked 2011-10-18 23:57:14 +0800

jaan gravatar image jaan
88 3

Hi,

I'm quite new to zk, so I probably overlook something.
I've created a composite component that implements AfterCompose
This source throws a "java.util.ConcurrentModificationException" at the point where I try to insertBefore.

oklbl is autowired.

public class MD extends Window implements AfterCompose {
	private Label oklbl;
       @Override
	public void afterCompose() {
		Executions.createComponents("/composites/MasterDetail.zul", this, null);
		
		
		Components.wireVariables(this, this); // auto wire variables
		Components.addForwards(this, this); // auto forward
		
		
		for(Component c: (List<Component>)this.getChildren())
			if(c instanceof Button) {
				this.insertBefore(oklbl, c)
			}
	}
}

How can I insert a control before another in afterCompose?
jaan

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-10-19 01:17:43 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2011-10-19 01:18:05 +0800

I think this is basic java ConcurrentModificationException when modify a List in it's element iteration.
I don't know what you are doing, however, regard to your code, you can try this

Button t = null;
for(Component c: (List<Component>)this.getChildren()){
	if(c instanceof Button) {
		t = (Button)c;
		break;
	}
}
if(t!=null){
	this.insertBefore(oklbl, t)
}

link publish delete flag offensive edit

answered 2011-10-19 02:03:27 +0800

jaan gravatar image jaan
88 3

Thank you!
That helped me a lot!

(pretty new to java too :) )
jaan

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: 2011-10-18 23:57:14 +0800

Seen: 481 times

Last updated: Oct 19 '11

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