# OnTimer stops scrolling on Ipad inside a Listbox

ansancle
317 9

ZK 6.5.1 EE The situation is a simple zul file with a listbox that needs to scroll on the Ipad. This problem does not occur on the desktop. It also happens if you have the listbox inside a scroll view or simply use "overflow:auto" on the listbox itself with no scrollview. You also have a timer component set to go off every 500 milliseconds. When you try and scroll, every time the timer goes off it stops the scrolling and "bounces" it back to the point you started at, making scrolling impossible.

To test the code just fix the packaging in the java and apply statement in the zul - or move the java code into the zul.

<zk>
<window border="none" id="_dhWindow" apply="com.dh.ui.ipad.view.TestView" height="100%" width="100%" xmlns:w="http://www.zkoss.org/2005/zk/client">

<!-- You can remove the vlayout and scrollview (non EE) and use
style="overflow:auto" on the listbox itself for same results -->
<vlayout>
<scrollview vflex="1" hflex="1">
<listbox id="_testList" width="100%" height="300px"/>
</scrollview>
</vlayout>

<timer id="_timer" delay="500" repeats="true" />
</window>

</zk>

/**
*
*/

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Window;

/**
* @author ansancle
*
*/
public class TestView extends GenericForwardComposer<Window>
{
private Listbox _testList;

* @see org.zkoss.zk.ui.util.GenericForwardComposer#doAfterCompose(org.zkoss.zk.ui.Component)
*/
@Override
public void doAfterCompose(Window comp) throws Exception
{

super.doAfterCompose(comp);
populateList();
}

private void populateList()
{
for (int i = 0;i< 100; i++)
{
Listitem item = new Listitem("Row " + i);
item.setParent(_testList);
}
}

}

delete retag edit

Hi, I can not reproduce the issue you meet. Either with or without scrollview component, the listbox scrolls well. I use ZK 6.5.1 and iOS 6.1.3 to test the problem. Can you provide more info?

( 2013-04-26 11:25:54 +0800 )edit

Sort by » oldest newest most voted

ansancle
317 9

This is very strange, I did some additional testing in the sandbox and it all worked fine. However, in my environment, the scrolling stops on the onTimer call even if there is no code in it. I even removed the method from my java file so only the <timer> is in the zul file and it still happened. Really doesn't make sense, the code I posted above will work in the sandbox no problem but in my regular run environment (jboss backend, apache, tomcat) it stops on every onTimer call. I will have to dig further and post what I find.

ansancle
317 9

From what I can tell - if all code is in the zul file it will work fine - even with a callback method for onTimer. I tested this in the sandbox. In my environment, it will work fine as long as there is no callback method in my java class. However, If you have a onTimer$_timer(Event event) in your java file that extends GenericForwardComposer it will stop the scrolling on the timer event. I even tried using javascript and Zau.send to see if I could get around it, that had the same results. <timer w:ontimer="useJavaScriptToSendTimerToJava();" repeat="true" delay="500"/> and the zAu.send called a method on the server in the java file to handle the updates, stops the scrolling every time it's called :( answered 2013-04-26 14:11:35 +0800 ansancle 317 9 As another means of testing, I tried the following using javascript instead of ZK to make the timeout and then call the server. This code caused the scrolling to stop on each timer event. <script type="text/javascript" > function handleOnTimerCall() { var dataArray = new Array(); dataArray[0] = ""; var windowWidget = zk.Widget.$('\$_dhWindow');
zAu.send(new zk.Event(windowWidget, 'onTimerCalled',dataArray));

}

var interval = setInterval(handleOnTimerCall,500);


However - when I removed the zAu call to the server, no interruption in the scrolling.

function handleOnTimerCall()
{

}

var interval = setInterval(handleOnTimerCall,500);


So calling the server is interrupting the scrolling for some reason. If everything is on the client no problem, but if you have to call the server it stops.

[hide preview]