-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, this problem only happens on IE7, not Firefox nor Chrome. Basically, my attached program below simulates situation where the user still have some records selected in the main table to be processed, when he picks a different category filter, a messagebox will pop up to prompt him to either proceed and lost the selected records OR go back to finish some work on the selected records. For simplicity purpose, the Unselected Record button simulates some action to be done on the selected records. The problem happens when I: select some records in the main table, change the Category, click No to the Messagebox prompt, and then click Unselected Record button. Although this button never calls the Messagebox, it still pops up a second time!! Any insight would be greatly appreciated. Thanks....
ZUL file:
======
<?xml version="1.0" encoding="UTF-8"?> <zk xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.zkoss.org/2005/zul' xmlns:h='http://www.w3.org/1999/xhtml' xsi:schemaLocation='http://www.zkoss.org/2005/zul WEB-INF/xsd/zul.xsd' anyAttribute= " "> <window id='testWin' use='ControllerTestWin' border='normal' title='A Test Page'> <label value='Select a category:'/><separator/> <!-- This is the movie category List box --> <listbox id='categoryLstBox' mold="select" rows="1" onSelect='testWin.categoryLstBox_onSelect()'> <listitem label='Cartoons' value='C' selected='true'/> <listitem label='ActionMovies' value='A' /> </listbox> <!-- CLick this button to display the Category movie details --> <space spacing='1px'/> <button id='displayBtn' label='Display Detail' autodisable='self' onClick='testWin.displayBtn_onClick()'/> <!-- Deselect button that simulates some actions on the selected records --> <space spacing='1px'/> <button id='unselectBtn' label='UnSelect Records' autodisable='self' onClick='testWin.unselectBtn_onClick()'/> <!-- This listbox display the movies names per selected Category --> <separator/> <listbox id='detailLstBox' width='400px' checkmark='true' multiple='true'> <listhead sizable='true'> <listheader label='Name'/> </listhead> </listbox> </window> </zk>
Controller file:
==========
import java.sql.SQLException; import javax.servlet.ServletContext; import java.util.*; import org.zkoss.zul.*; import org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.event.EventListener; /** Controller class for the verifyWindow page */ public class ControllerTestWin extends Window { private ZKCommonUtils zkCommonUtils = new ZKCommonUtils(); private List<String> nameList = new ArrayList(); private Map<String, String[]> nameHash = Collections.synchronizedMap(new HashMap()); private int existingSelectIndex = 0; /** Constructor */ public ControllerTestWin() { this.nameHash.put("C", new String[] {"Tom And Jerry", "Tweety and Sylvester", "Looney Toons"}); this.nameHash.put("A", new String[] {"Enter the Dragon", "Rumble in the Bronx", "Kickboxer"}); }//end constructor /** ===================Getter and Setter=============================== */ public void setNameList(List<String> nameList) { this.nameList = nameList; }//end method public List<String> getNameList() { return this.nameList; }//end method //=========================================================================== private Listbox getCategoryLstBox() throws Exception { return (Listbox) getFellow("categoryLstBox"); }//end method private Button getDisplayBtn() throws Exception { return (Button) getFellow("displayBtn"); }//end method private Listbox getDetailLstBox() throws Exception { return (Listbox) getFellow("detailLstBox"); }//end method // ======================Event Handlers====================================== public void categoryLstBox_onSelect() throws Exception { if (this.getDetailLstBox().getSelectedItems().isEmpty()) { this.existingSelectIndex = this.getCategoryLstBox().getSelectedItem().getIndex(); }//if no record selected else { Messagebox.show("There are still selected rows in the main table. \n " + "Click YES if you want to proceed without saving or \n " + "Click NO to go back and finish your work.", "Confirmation Prompt", Messagebox.YES | Messagebox.NO, Messagebox.QUESTION, new EventListener() { public void onEvent(Event evt) throws Exception{ switch (((Integer) evt.getData()).intValue()) { case Messagebox.YES: existingSelectIndex = getCategoryLstBox().getSelectedItem().getIndex(); getDetailLstBox().getChildren().clear(); break; case Messagebox.NO: //restore the previous selected item getCategoryLstBox().setSelectedIndex(existingSelectIndex); break; }//end switch }//end onEvent() }//end EventListener instance ); }//end if there're selected records }//end method public void displayBtn_onClick() throws Exception { String categoryKey = (String) this.getCategoryLstBox().getSelectedItem().getValue(); String[] categoryValue = this.nameHash.get(categoryKey); this.getDetailLstBox().getChildren().clear(); for (int i=0; i < categoryValue.length; i++){ Listitem listItem = new Listitem(categoryValue<i >, categoryValue<i >); listItem.setParent(this.getDetailLstBox()); }//end for }//end method public void unselectBtn_onClick() throws Exception { this.getDetailLstBox().clearSelection(); }//end method }//end class
Hi Ashishd, I use ZK ver. 5.0.3. Here're the user actions:
1. select Cartoons category
2. click Display Detail
3. check a few records checkboxes
4. select ActionMovies
5. click No button on the pop-up window (the pop-up doesn't show on my IE8)
6. click UnSelect Records (the pop-up re-appears a second time on my IE7)
7. if pop-up re-displays, just click No button
8. click UnSelect Records a second time, and the selected records will be unchecked.
So as you see in steps 5 and 6, I get 2 issues: pop-up doesn't show on my IE8; and pop-up re-appears a second time without being invoked on my IE7. Please let me know if you get the same symptoms on your system. Thanks Ashishd.
Hi zknewbie1,
I guess that is a bug, and here a workaround that you can invoke getCategoryLstBox().invalidate() to avoid this issue.
For example,
getCategoryLstBox().setSelectedIndex(existingSelectIndex); getCategoryLstBox().invalidate();
By the way, I post a bug here
Hi Ashishd, thanks very much for letting me know that both versions of IEs now work after Jumperchen's fix. My IE8 probably has some configs that blocks pop-up window. I'll play around with the configs to see if can allow pop-ups. Thanks...
Asked: 2010-08-27 16:35:10 +0800
Seen: 450 times
Last updated: Sep 08 '10