0

Exception on Desktop Destroy while modal window open !

asked 2012-12-07 18:39:23 +0800

csandeep gravatar image csandeep flag of India
66 5
http://sndpchatterjee07.w...

I have a .zul page(lets say A.zul) which has a button.In the corresponding composer class,the button's onClick eventHandler method pops up a modal window.
Now while the modal window is open,if I refresh the parent page A.zul,I encounter an java.lang.InterruptedException: Destroy desktop [Desktop z_2o70:........

Can anyone please help me on this ???


Thanks in advance guys....

delete flag offensive retag edit

20 Replies

Sort by ยป oldest newest

answered 2012-12-13 01:51:28 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

updated 2012-12-13 01:51:47 +0800

Hi Sandeep,

It is in the enterModal method itself, and interrupted by evtthd.ceaseSilently in desktopDestroyed0 (you can find the error message "Destroy desktop "+desktop here), then the catch block in enterModal will catch the InterruptedException and wrap it as a UiException then throw it.

You can verify this case by the simple sample below:

	public static void main (String args[]) {
		final Thread t = new Thread(new Runnable() {
			public void run () {
				new DoSomething().doSomething();
			}
		});
		t.start();
		Thread t2 = new Thread(new Runnable () {
			public void run () {
				try {
					Thread.sleep(2000);
					t.interrupt();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		});
		t2.start();
	}
	static class DoSomething {
		public synchronized void doSomething () {
			try {
				wait();
			} catch (InterruptedException e) {
				System.out.println(" oops ! interrupted !");
			}
		}
	}

Regards,
Ben

link publish delete flag offensive edit

answered 2012-12-07 21:27:24 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2012-12-07 21:33:14 +0800

How you try to refresh the a.zul ???

Think about if 'a.zul' is the 'Parent - Daddy' and holds his child in the air (the modal window) , what should happen with the 'child' if his Daddy is refresh/created new.

Try to call a method in the a.zul composer taht refresh the content/data and not the whole 'a.zul'

best
Stephan

PS: look here.
edit PS 2: can we change. You have such nice pics from where you live. Today we have here by me -7 degrees celsius. Brrrrrrrrr.

link publish delete flag offensive edit

answered 2012-12-08 07:29:04 +0800

csandeep gravatar image csandeep flag of India
66 5
http://sndpchatterjee07.w...

updated 2012-12-08 07:30:15 +0800

Thanks Stephan for your reply...

This is the scenario....

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Inside A.zul's composer
--------------------------------

public void onClick$button(){

		try{
			if(SOME CONDITION.....){
					
			}else{
					
				window = (Window)Executions.createComponents("B.zul", null , null);  // B.zul is the modal page.
						
				if(execution.getDesktop().isAlive()){  // STUCKKKKKKKKKKKKKKKKKKKKKKKKK............... 

					window.doModal();
							
				}
			}	
		}catch(Exception e){
		
			e.printStackTrace();
		}
}


Inside B.zul's composer..... [B.zul is actually a form which has a submit button(Lets say "closeBtn".]
--------------------------------

private Window modalDialog;

public void onClick$closeBtn(){

		try{
				// FETCH FORM VALUES... 
				
				modalDialog.detach();
		
		}catch(Exception e){
			
			e.printStackTrace();
		}
	}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

link publish delete flag offensive edit

answered 2012-12-08 10:34:42 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

i don't think you need:

. . .
if(execution.getDesktop().isAlive()){  // STUCKKKKKKKKKKKKKKKKKKKKKKKKK............... 
	window.doModal();
   }

window.doModal(); is enough

because you ARE in an 'execution'

2.

...
// FETCH FORM VALUES... 
modalDialog.onClose();

best
Stephan

link publish delete flag offensive edit

answered 2012-12-08 13:09:46 +0800

csandeep gravatar image csandeep flag of India
66 5
http://sndpchatterjee07.w...

Then how do I prevent the exception Stephan ?

I tried out the modalDialog.onClose() as well instead of modalDialog.detach() inside onClick$closeBtn(),didn't work out !


Regards,
Sandeep

link publish delete flag offensive edit

answered 2012-12-08 14:23:07 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2012-12-08 14:23:38 +0800

You should not prevent the exception. You should change the logic. (You don't show us the code how you refresh the 'a.zul'. And it seems that their is the problem )

Look at the text you are written in the starter thread.

You write that you get the exception as you will refresh the parent 'a.zul' from a modal window that is created from this parent.

All what i say is you should refresh the data/content of the a.zul file and not create the 'a.zul' new. than you will get no problem.

best
Stephan

link publish delete flag offensive edit

answered 2012-12-08 15:17:12 +0800

csandeep gravatar image csandeep flag of India
66 5
http://sndpchatterjee07.w...

I was trying to anticipate possible situations while the modal window is open.

Lets say: An end-user clicks the browser refresh button while the modal window is open !

link publish delete flag offensive edit

answered 2012-12-08 18:03:07 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

In this case the modal window is away and the parent zul file is loaded

link publish delete flag offensive edit

answered 2012-12-08 18:28:23 +0800

csandeep gravatar image csandeep flag of India
66 5
http://sndpchatterjee07.w...

updated 2012-12-08 18:30:31 +0800

Tell me one thing Stephan...


When window.doModal() is called,it must be handled by some thread,right ? Until an unless I am calling the detach() method,this thread is still alive.At this point,when I am refreshing the parent page A.zul,how is that thread handled ? I believe this is the reason why I am getting an java.lang.InterruptedException.

Please correct me if I am wrong....

link publish delete flag offensive edit

answered 2012-12-08 19:13:24 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2012-12-08 19:15:39 +0800

Hmmmmm, i think this stoped thread is still alive and cleaned up first if the timeout for the session comes. There are a few forum threads about this.

You can open the customer dialog in Zksample2 and refresh the browser. There's not your error. So i can only say i'm not understand why you will check in an execution if the execution is running well ??

public void onClick$closeBtn(){...

it's the same as:

public void onClick$closeBtn(Event event){...

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-12-07 18:39:23 +0800

Seen: 407 times

Last updated: Dec 13 '12

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