0

the XXXwindow.onClose fail to work when call the Onclose function in a messagebox event listner

asked 2009-12-25 01:29:10 +0800

wanlim0817 gravatar image wanlim0817
45

Hi,guys I have a problem confuse my few days

I have a listbox which contains data of article information.and when a user double click a listitem of article information.then will make a articledialogwindow doModal(i have disabled the event process thread,so actually It call the doHighlighted method).when the the article has been finished editing,then I call a messagebox to show up to the user,ask him whether to contine to add new information or return the artilce list.if he press the No button to retun to the article list,both the messagebox and aritlceinfowindow viusually have benn closed, then result a bug which I cann't select any listitem is the listbox when I click anyone of the listitem. this is the sever side code:
if (MessageBox.show(strBoxInfo, strBoxTitle,
Messagebox.YES | Messagebox.NO, Messagebox.QUESTION, true,
new EventListener() {
public void onEvent(Event evt) {

switch (((Integer) evt.getData()).intValue()) {
case Messagebox.YES:
doClear();
break;
case Messagebox.NO:
doClose();
break;
}
}

}) == Messagebox.YES) {
}

private void doClose() {
articleInfoDialogWindow.onClose();
}

then i use firebug to debug the zul.sel.wpd javascript file to look for the reason.when I click a listitem,call this method
doClick_: function(evt) {
if (this.isDisabled()) return;

evt.target = this;
this.getMeshWidget()._doClick(evt);// this function I think maybe the reason of the bug, and see it in the next code area
evt.stop({propagation: true});
this.$supers('doClick_', arguments);
},
this.getMeshWidget()._doClick(evt);
{
if (zk.dragging || this._shallIgnoreEvent(evt))
return;
/*
many code here
*/
}
_shallIgnoreEvent: function(evt) {
var tn = evt.domTarget.tagName;
return !evt.domTarget || !evt.target.canActivate() ||
((tn == "INPUT" && !evt.domTarget.id.endsWith('-cm')) ||
tn == "TEXTAREA" ||
(tn == "BUTTON" && !evt.domTarget.id.endsWith('-a')) ||
tn == "SELECT" ||
tn == "OPTION" ||
(zk.isLoaded('zul.wgt') && evt.target.$instanceof(zul.wgt.Button)))
},

canActivate: function (opts) {
var modal = zk.currentModal;
}
though i have close the articledialoginfo on the server side ,but the zk.currentModal value is not null and still represent the articleinfodialog in the client side. so then this cause me cannot select any listitem .cany anyone tell why the zk.currentModal vaule of client side still represent the articleinfodialog when I have close the aritlceinfodialog window by pressing the NO button of the messagebox on the server side.

thanks so much
Mike Lee

PS:I'm using the version of ZK5 RC2

delete flag offensive retag edit

15 Replies

Sort by ยป oldest newest

answered 2009-12-27 18:55:51 +0800

wanlim0817 gravatar image wanlim0817
45

can anybody help me?Please

thanks
Mike Lee

link publish delete flag offensive edit

answered 2009-12-28 19:08:46 +0800

wanlim0817 gravatar image wanlim0817
45

hhmmmmmmmmmm,can anybody give me a solution?

thanks
Mike Lee

link publish delete flag offensive edit

answered 2009-12-29 06:30:27 +0800

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

updated 2009-12-29 06:30:50 +0800

Please post us the stacktrace of your error message?

link publish delete flag offensive edit

answered 2009-12-29 21:37:20 +0800

wanlim0817 gravatar image wanlim0817
45

Hi,Stephan

there is no error in the java code on the server side.
When I close the aritlceinfowindow when click the "No" button of the messagebox.The windows is closed.
When I close the aritlceinfowindow ,the value of zk.currentModal on the client side should be null or undefined,but actually is not,it still represent the aritlceinfowindow.So Wehn I click a listitem that the method( this._shallIgnoreEvent(evt)) ) on the client side always return true, then I can't select any item in the listbox.

thanks
Mike Lee

link publish delete flag offensive edit

answered 2009-12-29 22:05:27 +0800

samchuang gravatar image samchuang
4084 4

updated 2009-12-30 05:12:08 +0800

Hi ~~

Could you kindly provide the simple version of your problem, include zul file and java code ?? it will help me a lot do the debug. Thank you for your help

Because I don't understand the UI operation flow that could cause your problem, so I can't produce the problem that you have.

link publish delete flag offensive edit

answered 2009-12-30 10:29:29 +0800

wanlim0817 gravatar image wanlim0817
45

Hi sam:

Tomorrow I will give you a simple version,can you tell me you email or other contact?

Thanks

Mike Lee

link publish delete flag offensive edit

answered 2009-12-30 16:12:47 +0800

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

(i have disabled the event process thread...

Hmmmmmmmmm, i'm not sure, but i think your code is run through the HighlightedDialog. Have you tried to give the Window an ID?
win.setID=""myWin";
So you can access it by ID if your components are autowired.

myWin.onClose();

link publish delete flag offensive edit

answered 2009-12-30 19:02:57 +0800

samchuang gravatar image samchuang
4084 4

updated 2009-12-30 19:03:14 +0800

@wanlim0817

Hi, you could post here and use "source code tag", it will help me read the code, or you could provide link to download, that will do.

link publish delete flag offensive edit

answered 2009-12-30 22:27:50 +0800

wanlim0817 gravatar image wanlim0817
45

I have enabled the event process thread.it still cause the problem.
And I also give the Window an ID.

Test.zul:click the btnAdd,then will open a Highlighted window(ps: the

openDialog.zul)

<?page title="artilcelist" contentType="text/html;charset=UTF-

8"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk>
	<window border="none" width="900px" height="500px" 

id="testWindow"
		use="zk.test.TestCtrl">
		<style>
			body { padding: 0 0; /* 0 padding on top and 

bottom and 0
			padding on right and left */ }
		</style>
		<borderlayout>
			<center flex="true" border="normal">
				<borderlayout height="100%" 

width="100%">
					<west collapsible="true" 

width="150px">
						<div>
							<button 

id="btnAdd" label="OpenDialog"></button>
						</div>
					</west>
					<center>
						<div height="100%">
							<paging 

id="paging_ArticleList" />
							<listbox 

id="lbxArticleList" width="100%"
								

height="100%" vflex="true" multiple="true">
								

<listhead sizable="true">
									

<listheader
									

	id="listheader_Article_id" sort="auto" width="5%" label="id" 

/>
									

<listheader
									

	id="listheader_Article_title" sort="auto" width="35%"
									

	label="title" />
									

<listheader
									

	id="listheader_Article_class" sort="auto" width="10%"
									

	label="class" />
									

<listheader
									

	id="listheader_Article_addTime" sort="auto" width="10%"
									

	label="add time" />
								

</listhead>
								

<listitem id="item1">
									

<listcell>1</listcell>
									

<listcell>title1</listcell>
									

<listcell>class1</listcell>
									

<listcell>add time1</listcell>
								

</listitem>
								

<listitem id="item2">
									

<listcell>2</listcell>
									

<listcell>title2</listcell>
									

<listcell>class2</listcell>
									

<listcell>add time2</listcell>
								

</listitem>
								

<listitem id="item3">
									

<listcell>3</listcell>
									

<listcell>title3</listcell>
									

<listcell>class3</listcell>
									

<listcell>add time3</listcell>
								

</listitem>
								

<listitem id="item4">
									

<listcell>4</listcell>
									

<listcell>title4</listcell>
									

<listcell>class4</listcell>
									

<listcell>add time4</listcell>
								

</listitem>
								

<listitem id="item5">
									

<listcell>5</listcell>
									

<listcell>title5</listcell>
									

<listcell>class5</listcell>
									

<listcell>add time5</listcell>
								

</listitem>
							</listbox>
						</div>
					</center>
				</borderlayout>
			</center>
		</borderlayout>
	</window>
</zk>


Test.zul JaveCode
package zk.test;

import java.io.Serializable;

import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Button;
import org.zkoss.zul.Window;

import cn.ipow.frontend.webui.util.BaseCtrl;

public class TestCtrl extends BaseCtrl implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -

8872141711397093531L;
	private transient Window testWindow;
	private transient Button btnAdd;

	public void onCreate$articleListWindow(Event event) throws 

Exception {
		doOnCreateCommon(testWindow);// autowire
	}
	//click event,open a window
	public void onClick$btnAdd(Event event) throws Exception {

		Window win = null;
		try {
			win = (Window) Executions.createComponents

("/openDialog.zul", null,
					null);
		} catch (Exception e) {

			if (win != null) {
				win.detach();
			}

		}
	}
}


openDialog.zul
<?page title="new page title" 

contentType="text/html;charset=UTF-8"?>
<zk>
	<window id="openDialogWindow" title="new page title" 

width="500px"
		height="300px" border="normal" closable="true"
		use="zk.test.OpenDialogCtrl">
		New Content Here!
		<button id="btnSave" label="Save"></button>
		<button id="btnClose" label="Close"></button>
	</window>
</zk>


openDialog java code
package zk.test;

import java.io.Serializable;

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Button;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;

import cn.ipow.frontend.webui.util.BaseCtrl;
import cn.ipow.frontend.webui.util.MultiLineMessageBox;

public class OpenDialogCtrl extends BaseCtrl implements Serializable {
	private transient Window openDialogWindow;
	protected transient Button btnSave;
	protected transient Button btnClose;

	public void onCreate$openDialogWindow(Event event) throws 

Exception {
		openDialogWindow.doModal(); // open the dialog in 

modal mode
	}

	public void onClick$btnSave(Event event) throws 

InterruptedException {
		if (Messagebox
				.show(
						"add success,choose ok 

to continue,choose no to close current window",
						"Notice", 

Messagebox.YES | Messagebox.NO,
						"z-msgbox z-msgbox-

question", new EventListener() {
							public void 

onEvent(Event evt) {

								switch 

(((Integer) evt.getData()).intValue()) {
								case 

Messagebox.YES:
									

// doClear();
									

break;
								case 

Messagebox.NO:
									

doClose();
									

break;
								}
							}

						}) == Messagebox.YES) 

{
		}
	}

	protected void doClose() {
		openDialogWindow.onClose();
	}

	public void onClick$btnClose(Event event) {
		doClose();
	}
}

this class(BaseCtrl)is just use to fininsh the auto wire

link publish delete flag offensive edit

answered 2009-12-31 00:31:32 +0800

samchuang gravatar image samchuang
4084 4

Hi

I modify your java code because I use GenericForwardComposer to do the autowire, beside that, It seems normal to me, seems woking good.

here is the code

OpenDialogCtrl.java

public class OpenDialogCtrl extends GenericForwardComposer{
	private transient Window openDialogWindow;
	protected transient Button btnSave;
	protected transient Button btnClose;
	
	public void onClick$btnSave(Event event) throws	InterruptedException {
		if (Messagebox.show(
			"add success,choose ok to continue,choose no to close current window",
			"Notice", Messagebox.YES | Messagebox.NO,
			"z-msgbox z-msgbox-question", new EventListener() {
			public void onEvent(Event evt) {
				switch (((Integer) evt.getData()).intValue()) {
				case Messagebox.YES:
					// doClear();
					break;
				case Messagebox.NO:
					doClose();
					break;
				}
			}
			}) == Messagebox.YES){
		}
	}

	protected void doClose() {
		openDialogWindow.onClose();
	}

	public void onClick$btnClose(Event event) {
			doClose();
	}
}


TestCtrl.java

public class TestCtrl extends GenericForwardComposer{
	private transient Window testWindow;
	private transient Button btnAdd;
	
	//click event,open a window
	public void onClick$btnAdd(Event event) throws Exception {
		
		Window win = null;
		try {
			win = (Window) Executions.createComponents("/openDialog.zul", null, null);
		} catch (Exception e) {
			if (win != null) {
				win.detach();
			}
		}
	}
}

openDialog.zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
	<window id="openDialogWindow" title="new page title" width="500px"
		height="300px" border="normal" closable="true"
		apply="zk.test.OpenDialogCtrl">
		New Content Here!
		<button id="btnSave" label="Save"></button>
		<button id="btnClose" label="Close"></button>
	</window>
</zk>

test.zul

<?page title="artilcelist" contentType="text/html;charset=UTF-

8"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk>
<window border="none" width="900px" height="500px" id="testWindow" apply="zk.test.TestCtrl">
	<style>
		body { padding: 0 0; /* 0 padding on top and bottom and 0 padding on right and left */ }
	</style>
<borderlayout>
	<center flex="true" border="normal">
	<borderlayout height="100%" width="100%">
		<west collapsible="true" width="150px">
			<div>
				<button id="btnAdd" label="OpenDialog"></button>
			</div>
		</west>
		<center>
			<div height="100%">
			<paging id="paging_ArticleList" />
			<listbox id="lbxArticleList" width="100%" height="100%" vflex="true" multiple="true">
				<listhead sizable="true">
					<listheader	id="listheader_Article_id" sort="auto" width="5%" label="id" />
					<listheader	id="listheader_Article_title" sort="auto" width="35%" label="title" />
					<listheader	id="listheader_Article_class" sort="auto" width="10%" label="class" />
					<listheader	id="listheader_Article_addTime" sort="auto" width="10%"	label="add time" />
				</listhead>
				<listitem id="item1">
					<listcell>1</listcell>
					<listcell>title1</listcell>
					<listcell>class1</listcell>
					<listcell>add time1</listcell>
				</listitem>
				<listitem id="item2">
					<listcell>2</listcell>							
					<listcell>title2</listcell>							
					<listcell>class2</listcell>
					<listcell>add time2</listcell>
				</listitem>
				<listitem id="item3">
				<listcell>3</listcell>
					<listcell>title3</listcell>
					<listcell>class3</listcell>
					<listcell>add time3</listcell>
				</listitem>
				<listitem id="item4">
					<listcell>4</listcell>
					<listcell>title4</listcell>
					<listcell>class4</listcell>
					<listcell>add time4</listcell>
				</listitem>
				<listitem id="item5">
					<listcell>5</listcell>
					<listcell>title5</listcell>
					<listcell>class5</listcell>
					<listcell>add time5</listcell>
				</listitem>
			</listbox>
			</div>
		</center>
	</borderlayout>
	</center>
</borderlayout>
</window>
</zk>

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: 2009-12-25 01:29:10 +0800

Seen: 711 times

Last updated: Jan 03 '10

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