0

Popup.open(Component ref) does not work correct in ZK3.6.1

asked 2009-05-20 09:41:22 +0800

kvegter gravatar image kvegter
54 2

Hi,

I have a problem with the menupopup. I create the popupmenu and show it when I click on a button in a row.
It works fine in ZK 3.6.0 however in ZK 3.6.1 it is broken. The popup menu is now not 'attached' to the button but placed under the rows of the grid with a 'greyed bar' on an unexpected place.

Please help, I will stay on 3.6.0 for now.

This code works fine in 3.6.0 but not 3.6.1:

private void addFolderActionsListener(Component comp) {
		    //
		    // first react on the onCLick event of the button
		    //
		    comp.addEventListener("onClick", new EventListener() {
		    	
				public void onEvent(Event arg0) throws Exception {
					// the folder is there 
					// 
					Button map = (Button) arg0.getTarget();
					DLFolder fold = getFolderContext(map);
					Menupopup mpop = null;
					if (fold != null) mpop = (Menupopup) getFellowIfAny("mpop_" + fold.getFolderId());
					else mpop = (Menupopup) getFellowIfAny("mpop_root");
					if (mpop == null) {
						mpop = new Menupopup();
						mpop.setParent(getWindow());
						if (fold != null) mpop.setId("mpop_" + fold.getFolderId());
						else mpop.setId("mpop_root");
						rowPopups.add(mpop);
						mpop.setAttribute("folder", fold);
						mpop.setAttribute("open", new Boolean(false));
						mpop.addEventListener("onOpen", new EventListener() {
							public void onEvent(Event arg0) throws Exception {
									showFolderPopupMenu(arg0.getTarget());
								}
							});
					
					}
					mpop.open(map);
				}
				
		});
	}

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-05-21 01:43:01 +0800

flyworld gravatar image flyworld
155 3

updated 2009-05-21 01:43:09 +0800

can you provide complete and executable code?
it makes others easy to duplicate you problems.

link publish delete flag offensive edit

answered 2009-06-08 08:36:17 +0800

kvegter gravatar image kvegter
54 2

updated 2009-06-08 08:43:06 +0800

Here is the complete and executable code. There is a normal popup menu on the "actions" button in zk3.6.0. But when using ZK 3.6.1 it fails (Tested on Chrome 2, Firefox 3 and IE 7).

I use the ZK plugin on eclipse to switch between zk library versions (project->properties->ZK/Package Setting). I am using tomcat 6.


here is the zul page:

<?page title="Test popupmenu" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="Test popupmenu" border="normal" use="com.test.zk.TestMenu" apply="com.test.zk.TestMenu">

</window>
</zk>

and here is the class (package com.test.zk)

package com.test.zk;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.Composer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Column;
import org.zkoss.zul.Columns;
import org.zkoss.zul.Grid;
import org.zkoss.zul.Label;
import org.zkoss.zul.Menuitem;
import org.zkoss.zul.Menupopup;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Row;
import org.zkoss.zul.Rows;
import org.zkoss.zul.Window;


public class TestMenu extends Window implements Composer{
	
	public void loadGrid() {
		Grid g = new Grid();
		g.setParent(this);
		Columns cols = new Columns();
		cols.setParent(g);
		Column col1 =new Column();
		col1.setParent(cols);
		col1.setWidth("200px");
		col1.setLabel("column one");
		Column col2 =new Column();
		col2.setParent(cols);
		col2.setWidth("100px");
		Rows rows = new Rows();
		rows.setParent(g);
		String[] rValues = new String[] {"Row one value", "Row two value "};
		// create rows
		for (String cur: rValues) {
			Row row = new Row();
			row.setParent(rows);
			Label label = new Label();
			label.setValue(cur);
			label.setParent(row);
			Button bAction = new Button();
			bAction.setParent(row);
			bAction.setLabel("actions");
			addActionMenu(bAction);
		}
		
	}
	private TestMenu getWindow() {
		return this;
	}
	private void addActionMenu(Component comp) {
		comp.addEventListener("onClick", new EventListener() {

			public void onEvent(Event arg0) throws Exception {
				Menupopup mpop = new Menupopup();
				// add to window
				getWindow().appendChild(mpop);
				// add items
				Menuitem itemOne = new Menuitem();
				itemOne.setParent(mpop);
				itemOne.setLabel("Item One");
				itemOne.addEventListener("onClick", new EventListener() {

					public void onEvent(Event arg0) throws Exception {
						Messagebox.show(" Item One clicked!");
					}
					
				});
				Menuitem itemTwo = new Menuitem();
				itemTwo.setParent(mpop);
				itemTwo.setLabel("Item Two");
				itemTwo.addEventListener("onClick", new EventListener() {

					public void onEvent(Event arg0) throws Exception {
						Messagebox.show(" Item Two clicked!");
					}
					
				});
				// open the menu
				mpop.open(arg0.getTarget());
			}
			
		});
		
		
	}
	public void doAfterCompose(Component win) throws Exception {
		TestMenu testMenu = (TestMenu) win;
		testMenu.loadGrid();
	}
	
	
	
}

link publish delete flag offensive edit

answered 2009-06-09 04:07:25 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

It works fine on newest ZK.
you can download the freshly version and try again :)
https://sourceforge.net/project/showfiles.php?group_id=152762

BTW, the 3.6.2 will be released at 6/22

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-05-20 09:41:22 +0800

Seen: 650 times

Last updated: Jun 09 '09

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