-
FEATURED COMPONENTS
First time here? Check out the FAQ!
We are trying to call the scrolling event for the center layout in the application. But the scroll event is not getting called.
<center id="mainlayoutCenterCanvas" xmlns:w="client" w:onScroll='console.log("scroll a")'autoscroll="true">
<div id="mainLayoutFullfill" xmlns:w="client" w:onScroll='console.log("scroll b")' fulfill="=../WEB-INF/zul/qa/layout/center.zul"/>
</center>
And in the center.zul we have :
<vlayout id="centerAreaCanvas" xmlns:w="client" w:onScroll='console.log("scroll center")'>
For all the above components we have added an event listener in Java also as:
public Center getMainlayoutCenterCanvas() {
Center mainlayoutCenterCanvas = (Center)getFellowIfAny("mainlayoutCenterCanvas");
mainlayoutCenterCanvas.addEventListener(Events.ON_SCROLL, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
// TODO Auto-generated method stub
System.out.print("check");
}
});
mainlayoutCenterCanvas.addEventListener(Events.ON_SCROLLING, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
// TODO Auto-generated method stub
System.out.print("check");
}
});
return mainlayoutCenterCanvas;
}
Div mainLayoutFullfill;
public void addListenerToCenter() {
if(centerAreaCanvas == null) {
centerAreaCanvas = (Vlayout)getFellowIfAny("centerAreaCanvas");
centerAreaCanvas.addEventListener(Events.ON_SCROLL, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
// TODO Auto-generated method stub
System.out.print("check a");
}
});
centerAreaCanvas.addEventListener(Events.ON_SCROLLING, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
// TODO Auto-generated method stub
System.out.print("check a");
}
});
}
if(mainLayoutFullfill == null) {
mainLayoutFullfill = (Div)getFellowIfAny("mainLayoutFullfill");
mainLayoutFullfill.addEventListener(Events.ON_SCROLL, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
// TODO Auto-generated method stub
System.out.print("check b");
}
});
mainLayoutFullfill.addEventListener(Events.ON_SCROLLING, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
// TODO Auto-generated method stub
System.out.print("check b");
}
});
}
}
But none of the events are getting called. What is wrong here What can we do? I need to get Y position(Vertical scroll position on scrolling and save it)
zul.layout.LayoutRegion._doScroll()
fires events with zWatch
_doScroll: function () {
zWatch.fireDown('onScroll', this);
},
You need to listen with zWatch
Because fireDown() only invokes a listener on an event's target's descendants, you need to register a listener on the center's child component.
<borderlayout>
<north height="500px" autoscroll="true">
<div height="1000px">
north
</div>
</north>
<center id="mainlayoutCenterCanvas" autoscroll="true">
<div id="main" height="1000px">
content in center
</div>
</center>
<south height="300px">
south
</south>
</borderlayout>
<script defer="true" src="scrollListener.js"/>
var div = zk.Widget.$('$main');
div.onScroll = function(controller){
console.log(controller);
}
zWatch.listen({
onScroll: div,
});
get vertical scroll position
div.onScroll = function(controller){
console.log(controller.origin.$n('cave').scrollTop);
}
Asked: 2022-02-22 17:24:02 +0800
Seen: 8 times
Last updated: Mar 07 '22
zkspringmvc jar licence is GPL ?
Build web application without any zul files
Custom component that extends Textbox does not fire onChange event
java.lang.NullPointerException to update to zk 8.0.1
"Spring Session" + ZK + "Spring core" @Listen method refresh the screen
zk8 client side binding to a viewmodel command seems not to work
upload event dialog do not open in browser
Notification is not shown inside sticky block
Where can I find documentation (like ZK Developer's Reference) for ZK 8.0.2.2 ?