-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have this code:
@Listen ("onSort = #LBSeguimiento > listhead > listheader") public void ordenar(Event se){ if(((SortEvent)se).isAscending()){ //Do something } }
It gaves me an exception saying that event can not be cast to sortevent
21-nov-2012 8:59:25 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1351 GRAVE: >>java.lang.ClassCastException: org.zkoss.zk.ui.event.Event cannot be cast to org.zkoss.zk.ui.event.SortEvent >> at org.sts.generales.PlantillasZul.NuevoSeguimientoSelector.ordenar(NuevoSeguimientoSelector.java:493) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) >> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) >> at java.lang.reflect.Method.invoke(Unknown Source) >> at org.zkoss.zk.ui.select.Selectors$ComposerEventListener.onEvent(Selectors.java:683) >> at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2734) >> at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2705) >> at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2646) >> at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136) >> at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process0(EventProcessingThreadImpl.java:534) >> at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.run(EventProcessingThreadImpl.java:461)
It works until I updated to the ZK build zk-6.0.3-FL-2012-10-24 (I can't tell you which build I have before updating).
I need to know which kind of sorting is executed. How can I get the sort event??
Thank you!
It says that my event is not a ForwardEvent (getRealOrigin() needs a ForwardEvent).
It's strange because it was working with older ZK 6.1 builds and one day I updated the freshly build and I just couldn't get the event anymore
Sorry, probably not helping at all - you need a java man, my java programmer ain't in today.
In python we anyway do it different :-
def onSort_comp_col(self,event): real_event = Events.getRealOrigin(event) real_event.stopPropagation(); if self.comp_col.getSortDirection() == "natural": self.comp_col.setSortDirection("ascending") self.model.setOrderBy("a_name asc") else: if self.comp_col.getSortDirection() == "ascending": self.comp_col.setSortDirection("descending") self.model.setOrderBy("a_name desc") else: self.comp_col.setSortDirection("ascending") self.model.setOrderBy("a_name asc")
This code will probably just confuse you.
"comp_col" is the id of the column being sorted
<treecol id="comp_col" sortDirection="natural" sort="auto"> <label multiline="true"> Component Type </label> </treecol>
In ZK 6.0.x and previous versions, ListHeader components post generic Events instead of SortEvents, so it's not possible to get a SortEvent.
You'll need to upgrade to ZK 6.5.x if you want SortEvents.
The relevant change/feature that was implemented in ZK 6.5.x is ZK-120, and the git commit is a32d2bf383c0d7e07fd6e5a9e122da21ae898bb7
But before upgrading to the Freshly build of day 10/24/2012 I was doing it. (My build was 6.1.0-FL-2012-06-11) that's why I think that something was broken.
So, there's no way to know if the column is sorted ascending or descending?
Thank you for your answer anyway
As far as I know, 6.1 was renamed to 6.5, so those freshlies contained the change, but ZK 6.0.x does not have this change.
You have essentially downgraded ZK if you went from 6.1 to 6.0.3, and you no longer have that feature available.
Asked: 2012-11-21 08:11:35 +0800
Seen: 132 times
Last updated: Nov 30 '12