0

Exception thrown when Execution.createComponents

asked 2012-03-19 20:15:26 +0800

Sterling gravatar image Sterling
36

Hello Everyone,

I am trying to get a window to popup from my main window without having the popup zul code within the main zul code. For this, I used Execution.createComponents as discussed here: http://www.zkoss.org/forum/listComment/8781 and for some reason an exception is thrown every time even though the window still pops up and controller code for the window still functions properly.

Here is the code I am using:

[code
try
{
ChangePasswordWin = (Window)Executions.createComponents( "/IndexWindows/ChangePassword.zul", null, null );
ChangePasswordWin.setParent(index);
ChangePasswordWin.doOverlapped();
}
catch(Exception exc)
{
System.out.println("Exception thrown");
}


I guess what I'm asking is this code correct? I get unusual errors (although my controller code still works).

Also something to note is that if I do not setParent to index I get these lines in red output when the window pops up (window still pops up and functions properly):


Mar 19, 2012 1:00:38 PM org.zkoss.zk.ui.metainfo.Property assign:175
SEVERE: Failed to assign [id=ChangePasswordWin] to <Window p4OBs0>
Not unique in ID space [Page p4OB_]: ChangePasswordWin

When I comment out the setParent(index) line, those lines don't show up when I run the window but after either closing, or submitting changes, when I try to reopen the window I get the same error and the window will now not open. I do not have any detach statement in the controller for ChangePasswordWin but the window is seemingly still detached.

The code I have for this window still works and still updates my database but this still concerns me. Also my window is getting detached and I don't want it to! 

Please Help!

Sterling

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-03-19 20:30:08 +0800

gekkio gravatar image gekkio flag of Finland
899 1
http://gekkio.fi/blog

The problem is that you have assigned the window an ID, and you must only have one window instance with that ID.
That's what the error "Not unique in ID space" means.
I'm a bit surprised that setParent fails due to this, but you can work around the problem by passing the parent to Executions.createComponents:

Executions.createComponents( "/IndexWindows/ChangePassword.zul", index, null );

That makes the manual call to setParent unnecessary.

Executions.createComponents will always create new components and never returns old ones.
If the window is not detached when closed, it will stay in the id space. The next time you call createComponents, you are creating another window with the same id and you have two windows on the page which doesn't work. You must either

1. Detach the window on close and forget about it. When you call createComponents, you get another window but there is no conflict since the first one was detached.
2. Don't use createComponents at all. You must store the window reference somewhere and call doOverlapped manually when you want to reopen the window

link publish delete flag offensive edit

answered 2012-03-19 22:30:28 +0800

Sterling gravatar image Sterling
36

Thank you for your reply, gekkio.

That clarifys one of the problems about my window being detached but I am still having trouble. The exception is still being thrown, odly. And also the window is unable to be reopened after submitting/closing. i.e. when I click the reset password button, the window opens correctly (aside for the exception being thrown) Then i can either submit new results or close the window (which both work correctly) but after trying to reopen the window I get that nasty...

"Mar 19, 2012 1:00:38 PM org.zkoss.zk.ui.metainfo.Property assign:175
SEVERE: Failed to assign [id=ChangePasswordWin] to <Window p4OBs0>
Not unique in ID space [Page p4OB_]: ChangePasswordWin"

...error

Any other thoghts that may help me out? I can give more code if needed =)

link publish delete flag offensive edit

answered 2012-03-19 23:13:10 +0800

Sterling gravatar image Sterling
36

Ok nevermind that. I understood what you said now gekkio. I removed the id from the ChangePassword.zul file and it stopped throwing my exception =D hurray!

Now that the id is gone though, I cant figure out how to detach the window. It does not do it automatically. Could you tell me how to detach the child window from within my index window without the id?

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: 2012-03-19 20:15:26 +0800

Seen: 238 times

Last updated: Mar 19 '12

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