0

window scroll when opeing/filling combobox

asked 2009-05-29 08:02:19 +0800

oda38 gravatar image oda38
9 1

hi,

when opening a combobox the position of my window is modified. i.e there is
some sort of (horrible) scroll down effect.
FYI combobox is filled dynamically on onOpen event.

How can i keep initial position of the window when opening combobox?

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2009-05-29 08:08:46 +0800

oda38 gravatar image oda38
9 1

here is part of the code called when opening conmbobox:

deviceCombo.addForward("onOpen", this, "onRefreshDevice", deviceCombo);

public void onRefreshDevice(Event event) {
Combobox devicesCombo = (Combobox) event.getData();
devicesCombo.getChildren().clear();
Device selected = phone.getDevice();

Comboitem item = null;

boolean chooseNextAsDefault = (selected == null);

for (Device device : this.profile.getDevices()) {
item = new Comboitem();
item.setValue(device);
item.setLabel(device.getVisibleName());

devicesCombo.appendChild(item);
if (selected != null && device.getId() == selected.getId()) {
devicesCombo.setSelectedItem(item);
} else if (chooseNextAsDefault) {
devicesCombo.setSelectedItem(item);
this.phone.setDevice(device);
chooseNextAsDefault = false;
}
}
}

link publish delete flag offensive edit

answered 2009-06-01 01:55:27 +0800

PeterKuo gravatar image PeterKuo
481 2

I can't reproduce your situation by your sample code.
Maybe you can provide more code that can let others easily reproduce your situation.

Do you enclose the combobox with a window component?
I tried in zk live demo, browse by firefox 3, the popup of combobox won't affect window position.
http://www.zkoss.org/zkdemo/userguide/#f5

But I do notice something strange in your code:
deviceCombo.addForward("onOpen", this, "onRefreshDevice", deviceCombo);
Is deviceCombo a component? or an event?
http://www.zkoss.org/javadoc/3.6/zk/org/zkoss/zk/ui/Component.html

link publish delete flag offensive edit

answered 2009-06-01 09:38:55 +0800

oda38 gravatar image oda38
9 1

here is a zul and its associated java code...

-----------
<?page title="voip profile configuration" contentType="text/html;charset=UTF-8"?>
<zk>
<window id="win" border="normal" use="com.ubiqube.ses.zk.window.voip.BugCBWindow" xmlns:a="http://www.zkoss.org/2005/zk/annotation"
contentStyle="overflow:auto">
<vbox>
<hbox>
<label>testbug</label>
<combobox id="cb_bug">
</combobox>
</hbox>
</vbox>

<zscript>
win.init();
</zscript>
</window>
</zk>
-----------

import org.apache.log4j.Logger;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Window;

public class BugCBWindow extends Window {
private static final long serialVersionUID = 1L;
final static Logger logger = Logger.getLogger(BugCBWindow.class.getName());

public BugCBWindow() {
}

public void init() throws Exception {
try {
updateCBBug();
} catch (Exception e) {
throw new Exception(e.getMessage());
}
}

public void updateCBBug() throws Exception {
Combobox bugCB = (Combobox) getFellow("cb_bug");
chooseDefaultSelectedItem(bugCB);
bugCB.addForward("onOpen", this, "onOpenCB", bugCB);
}

public void onOpenCB(Event event) {
Combobox combobox = (Combobox) event.getData();

Comboitem item = combobox.getSelectedItem();
String selectedValue = (item == null) ? null : (String) combobox.getSelectedItem().getValue();

combobox.getChildren().clear();

for (int i = 0; i < 15; i++) {
String value = "" + i;

item = new Comboitem();
item.setValue(value);
item.setLabel(value);

combobox.appendChild(item);
if (selectedValue != null && value.equals(selectedValue)) {
combobox.setSelectedItem(item);
}
}
}

public static Combobox chooseDefaultSelectedItem(Combobox combobox) {
combobox.getChildren().clear();

String selectedValue = "" + 1;

Comboitem item = new Comboitem();

item.setValue(selectedValue);
item.setLabel(selectedValue);
combobox.appendChild(item);
combobox.setSelectedItem(item);

return combobox;
}
}

link publish delete flag offensive edit

answered 2009-06-05 04:10:11 +0800

PeterKuo gravatar image PeterKuo
481 2

By deploy your sample code, and browser by ff3, I still not seen position of my window is modified
But I see the combobox window tremble.
To avoid such tremble, you may make combobox invisible, then clear its children, append child, then make combobox visible.

link publish delete flag offensive edit

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

charanya1605 gravatar image charanya1605
18

hi,which version of ZK are you using?We use 3.6.1 and we do see that opening a combobox which already has an item selected makes the window scroll as if it sets focus on the combobox.Can anyone tell if code was modified to set focus on it onOpen? We dont see any such change in the code.Thanks!

link publish delete flag offensive edit

answered 2009-06-08 09:21:42 +0800

timshiu gravatar image timshiu
51

updated 2009-06-08 09:22:30 +0800

Actually, I have the same problem as oda38 by using IE7.
The problem only be reproduced when scroll bar is shown in the browser.
First of all, select any item from the list. Then press DOWN arrow button on keyboard.
The window will put the combobox on the top of browser (for both IE7 and FF3) and the (horrible) scroll down effect will be appeared. (For IE7 only)

The following is the sample code to demonstrate the above issue.
<?page title="Combobox Testing" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="Combobox Testing" border="normal">
<combobox id="cbbMain" autocomplete="false" autodrop="true">
<comboitem label="Apple" />
<comboitem label="Banana" />
<comboitem label="Cat" />
<comboitem label="Dog" />
<comboitem label="Egg" />
<comboitem label="Fox" />
<comboitem label="Girl" />
<comboitem label="Ham" />
</combobox>
<separator height="1000px" /> <!-- Show the vertical scroll bar -->
</window>
</zk>

P.S. I'm using ZK 3.6.1.

link publish delete flag offensive edit

answered 2009-06-08 11:21:25 +0800

PeterKuo gravatar image PeterKuo
481 2

Thanks timshiu, I reproduced this bug.
I posted it to sourceforge bug , please refer to following link.
https://sourceforge.net/tracker/?func=detail&aid=2802858&group_id=152762&atid=785191

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-29 08:02:19 +0800

Seen: 1,210 times

Last updated: Jun 08 '09

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