-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
can anybody help me?Please
thanks
Mike Lee
hhmmmmmmmmmm,can anybody give me a solution?
thanks
Mike Lee
Please post us the stacktrace of your error message?
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
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.
Hi sam:
Tomorrow I will give you a simple version,can you tell me you email or other contact?
Thanks
Mike Lee
(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();
@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.
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>
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(); } } } }
<?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>
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(); } }
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>
Asked: 2009-12-25 01:29:10 +0800
Seen: 711 times
Last updated: Jan 03 '10