0

How can I get the original event??

asked 2012-11-21 08:11:35 +0800

Neus gravatar image Neus
1415 14

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!

delete flag offensive retag edit

10 Replies

Sort by ยป oldest newest

answered 2012-11-27 10:15:53 +0800

Neus gravatar image Neus
1415 14

Any idea about this? Or any alternative?

link publish delete flag offensive edit

answered 2012-11-30 10:48:43 +0800

Neus gravatar image Neus
1415 14

I'm still getting this exception

link publish delete flag offensive edit

answered 2012-11-30 11:29:31 +0800

Bobzk gravatar image Bobzk
428 1 5

Have a look at "getRealEvent"

Python code is :-

real_event = Events.getRealOrigin(event)

where "event" would be "se" in your above code.

link publish delete flag offensive edit

answered 2012-11-30 12:10:43 +0800

Neus gravatar image Neus
1415 14

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

link publish delete flag offensive edit

answered 2012-11-30 12:28:30 +0800

Bobzk gravatar image Bobzk
428 1 5

Can you print out the event type?

Python would be :-

print type(event)

but don't know java equivalent off the top of my head.

link publish delete flag offensive edit

answered 2012-11-30 12:46:48 +0800

Bobzk gravatar image Bobzk
428 1 5

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>

link publish delete flag offensive edit

answered 2012-11-30 12:54:05 +0800

Neus gravatar image Neus
1415 14

If I make a event.getClass() it returns that the event is a generic type Event.
I can get the Name of the event too. Its name is onSort but I can't cast it to SortEvent.

link publish delete flag offensive edit

answered 2012-11-30 13:35:44 +0800

gekkio gravatar image gekkio flag of Finland
899 1
http://gekkio.fi/blog

updated 2012-11-30 13:36:03 +0800

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

link publish delete flag offensive edit

answered 2012-11-30 13:46:53 +0800

Neus gravatar image Neus
1415 14

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

link publish delete flag offensive edit

answered 2012-11-30 13:55:29 +0800

gekkio gravatar image gekkio flag of Finland
899 1
http://gekkio.fi/blog

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.

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: 2012-11-21 08:11:35 +0800

Seen: 132 times

Last updated: Nov 30 '12

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