0

Listbox + context menu + modal window

asked 2010-07-16 17:48:18 +0800

andreasboos gravatar image andreasboos
105 3

I have a problem in the context menu when it runs on a grid and it is in a modal window. The problem is this: when I click on an item ON_CLICK the event is not fired, but if I keep trying to insist and he ends up happening. It sounds like the area click "decreases". When I open the window as embedded works perfectly.

Unfortunately there is no way I paste an example here, because our program is generated at runtime. And everything is made with pure Java.

We use ZK version 5.0.3 and tested in IE 8 and firefox 3.6.3.

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2010-07-18 21:44:31 +0800

SimonPai gravatar image SimonPai
1696 1

Hi andreasboos,

I tried the combination you mentioned, but I didn't spot the issue. The following is my test case:

<zk>
	<button label="go" onClick="modal1.doModal();" />
	<window id="modal1" title="Window: Modal" border="normal" visible="false"
		width="300px" height="200px">
		<vbox>
			<grid>
				<rows>
					<row context="pop">Row 1</row>
					<row context="pop">Row 2</row>
					<row context="pop">Row 3</row>
				</rows>
			</grid>
			<menupopup id="pop">
				<menuitem label="Menu 1" onClick='lb.value="1"' />
				<menuitem label="Menu 2" onClick='lb.value="2"' />
				<menuitem label="Menu 3" onClick='lb.value="3"' />
			</menupopup>
			<label id="lb" value="" />
			<div>
				<button label="Close" onClick="modal1.visible = false;" />
			</div>
		</vbox>
	</window>
</zk>

I understand that you can't extract a test zul file for this issue, but can you reproduce the problem in a Composer or a piece of Java code? If so that would help a lot.

Regards,
Simon

link publish delete flag offensive edit

answered 2010-07-19 07:42:21 +0800

andreasboos gravatar image andreasboos
105 3

Hello
We are not using grid but listbox. I do not know if that influences anything. Anyway I will try to reproduce the problem in java.
Our system generates screens based on a configuration file that has the coordinates to fit the screen. All this basically using reflection with. SetParent (). Our listbox has this method:

private GridOnClickContextMenuEvent menuEvent = new GridOnClickContextMenuEvent();
private void initContextMenu() {
try {
mp.setWidth("200px");
mp.setPage(getPage());
setContext(mp);

Menuitem miImprimir = new Menuitem();
Menuseparator ms1 = new Menuseparator();
Menu mnColunas = new Menu();
Menupopup mpColunas = new Menupopup();
//mpColunas.addEventListener(Events.ON_CLICK, menuEvent);

miImprimir.setLabel("Imprimir");
miImprimir.setImage("/images/print.gif");
miImprimir.setAttribute("name", "imprimir");
miImprimir.addEventListener(Events.ON_CLICK, menuEvent);
mnColunas.setLabel("Colunas");
mnColunas.setImage("/images/settings.gif");
mnColunas.setAttribute("name", "mncolunas");

int count = 0;
for (TXGridColumn column : this.getxColumns()) {
Menuitem mi = new Menuitem();
mi.setLabel(column.getxCaption());
mi.setCheckmark(true);
mi.setChecked(column.isVisible());
mi.setParent(mpColunas);
mi.setAttribute("name", "column" + count++);
mi.addEventListener(Events.ON_CLICK, menuEvent);
}
miImprimir.setParent(mp);
ms1.setParent(mp);
mnColunas.setParent(mp);
mpColunas.setParent(mnColunas);
} catch (Exception e) {
e.printStackTrace();
}
}

private class GridOnClickContextMenuEvent implements EventListener {
@Override
public void onEvent(Event event) throws Exception {
if (event.getTarget().getAttribute("name").equals("imprimir")) {
TXGridReport fr = new TXGridReport(TXGrid.this, _xReportTitle!=null?_xReportTitle:"Título", _xReportSubTitle!=null?_xReportSubTitle:"Sub-Título");
fr.setParent(getPage().getFirstRoot());
fr.setVisible(true);
fr.doModal();
} else {
Menuitem item = (Menuitem)event.getTarget();
TXGridColumn comp = (TXGridColumn) TXGrid.this.getListhead().getChildren().get(
Integer.parseInt(event.getTarget().getAttribute("name")
.toString().replaceAll("[^0-9]", "")));
comp.setVisible(!item.isChecked());
((Menuitem)event.getTarget()).setChecked(!item.isChecked());
}
}
}


In it we've enabled the user can remove columns from the listbox and also able to print the data.

Our screen is mounted using this file zul:


<?xml version="1.0" encoding="UTF-8"?>
<?init zscript="imports.zul"?>
<txform
apply="webeasy.renderizer.Renderizer"
style="position: absolute;"
onOK="onEnter(event)"
sizable="true">

<script src="/javascript/jquery-1.3.2.min.js"></script>
<script src="/javascript/jquery.maskedinput-1.2.2.min.js"></script>
<zscript>
void onEnter(Event event) {
Component comp = event.getReference();
Component next = comp.getNextSibling();
if (next != null)
next.focus();
}
</zscript>
</txform>

Where TXGridColumn extends the class and listhead, txform extends Window and Renderizer extends GenericAutowireComposer. When data is loaded into the listbox I execute the method initContextMenu.

Everything works perfectly when the listbox is in an embedded window. But when I open the modal and clicking on menu items do not work. Or work after much stress.

Thanks for the help.

link publish delete flag offensive edit

answered 2010-07-20 02:02:11 +0800

SimonPai gravatar image SimonPai
1696 1

andreasboos,

I tried to make a test case from you code with some modifications (to make it runnable), but I still can't reproduce the problem. This is the current test code I have:

zul

<zk>
	<button label="go" onClick="modal1.doModal();" />
	<window id="modal1" visible="false" title="Modal Window" border="normal" 
		width="300px" height="300px" apply="foo.Comp1">
		<listbox>
			<listhead>
				<listheader context="mp">Header</listheader>
			</listhead>
			<listitem>
				<listcell>
					<label value="Label" context="mp" />
				</listcell>
			</listitem>
		</listbox>
		<menupopup id="mp" />
		<popup id="pop" >Event Fired</popup>
	</window>
</zk>

Comp1.java

public class Comp1 extends GenericForwardComposer {
	private static final long serialVersionUID = 1L;
	
	private Popup pop;
	private Menupopup mp;
	
	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		
		GridOnClickContextMenuEvent menuEvent = new GridOnClickContextMenuEvent();
		
		Menuitem miImprimir = new Menuitem();
		Menuseparator ms1 = new Menuseparator();
		Menu mnColunas = new Menu();
		Menupopup mpColunas = new Menupopup();
		
		miImprimir.setLabel("Imprimir");
		miImprimir.setAttribute("name", "imprimir");
		miImprimir.addEventListener(Events.ON_CLICK, menuEvent);
		mnColunas.setLabel("Colunas");
		mnColunas.setAttribute("name", "mncolunas");
		
		int count = 0;
		for (int i = 0; i < 9; i++) {
			Menuitem mi = new Menuitem();
			mi.setLabel("Menuitem "+i);
			mi.setCheckmark(true);
			mi.setChecked(true);
			mi.setParent(mpColunas);
			mi.setAttribute("name", "column" + count++);
			mi.addEventListener(Events.ON_CLICK, menuEvent);
		}
		miImprimir.setParent(mp);
		ms1.setParent(mp);
		mnColunas.setParent(mp);
		mpColunas.setParent(mnColunas);
	}
	
	private class GridOnClickContextMenuEvent implements EventListener {
		@Override
		public void onEvent(Event event) throws Exception {
			pop.open(mp);
			System.out.println("Event Fired");
		}
	}
}

If you can provide a runnable test code or some more clues then maybe we can locate the issue better.
Meanwhile I will also continue to think about what are the possible causes.

Simon

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: 2010-07-16 17:48:18 +0800

Seen: 982 times

Last updated: Jul 20 '10

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