0

onSize event not called on Window!!!

asked 2008-12-16 08:55:54 +0800

nat gravatar image nat
195 3

Dear All
Am quite new in web application field. My zk application need to fire some event when user resizes the browser window.
In my zul page I defined an "onSize" event to catch... But it seems this event is never fired when user resizes its window..!
What am I doing wrong?? Could somebody help me figure out?
Thanks in advance.
-nat

delete flag offensive retag edit

12 Replies

Sort by ยป oldest newest

answered 2008-12-16 15:14:40 +0800

nat gravatar image nat
195 3

So really there is no way to catch "onResize()" event in ZK?
Any hint or help is welcome! Please Help!
-nat

link publish delete flag offensive edit

answered 2008-12-18 04:32:38 +0800

robertlee gravatar image robertlee
561

Hi Nat, i tried following:

<window title="My First Window" border="normal" width="200px" onSize='Messagebox.show("hey");' sizable="true">
  Hello, World!
</window>

and

<window title="My First Window" border="normal" width="200px" sizable="true">
<attribute name="onSize">
Messagebox.show("Hello");
</attribute>
  Hello, World!
</window>

These two are for window's onSize event.

if you want to send a custom event, see:

"Inter-Page Communication" in developers guide. (so you know how to use sendEvent/postEvent).

link publish delete flag offensive edit

answered 2008-12-18 07:43:05 +0800

nat gravatar image nat
195 3

I see...
Thanks Robertlee for your answer. If I understand, this event is fired only if window is sizable. It's maybe not exactly the kind of behavior am expexting.
What I want is the same behavior as in a normal html body tag like this:
<body onresize="resize()" >
...
</body>
I want to catch if user has resized browser window or not.
Thanks anyway and Season Greatings!
-nat

link publish delete flag offensive edit

answered 2008-12-18 11:12:03 +0800

PeterKuo gravatar image PeterKuo
481 2

In such case, I think you should use Client Side Actions.
Please refer to http://www.zkoss.org/doc/devguide-single/index.html#id4871344

link publish delete flag offensive edit

answered 2009-01-06 08:37:45 +0800

nat gravatar image nat
195 3

I am fighting since 3 weeks with this problem and haven't found a solution yet.
I suppose ZK cannot do this? catching the body onresize() event? I know it's possible (at least with html and jsp) but nobody has an idea how to do this with zk?
Do I have to mix html with zk in order to produce the desired effect or go back to my traditional jsp's?
Thanks anyway.
-nat

link publish delete flag offensive edit

answered 2009-01-07 02:02:01 +0800

robertlee gravatar image robertlee
561

Hi nat,
Should this post explain:

http://bytes.com/groups/javascript/430012-body-onresize-vs-window-onresize

Regards,
Robert

link publish delete flag offensive edit

answered 2009-01-07 13:16:30 +0800

nat gravatar image nat
195 3

Hi Robertlee
Am simply dazzed!.. So There is no onresize attribute for the body element in a Valid HTML?!! Woaw! I never know this before.
Is this meaning THERE IS NO WAY TO CATCH BROWSER RESIZE EVENT???
Thanks anyway.
-nat

link publish delete flag offensive edit

answered 2009-01-17 11:06:52 +0800

robertlee gravatar image robertlee
561

updated 2009-01-19 10:29:17 +0800

Hi nat,

I have figured out a way, and I must say its a very interesting problem to me:

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
	<window title="new page title" border="normal">
		<script type="text/javascript">
			window.onresize= message;
			function message() {
				var mye = document.getElementsByTagName('a');
				for(i=0;i&lt;mye.length;i++){
					comm.sendEvent(mye[ i ], 'onUser', 'data from window');
				}
			}
			</script>
		<div xmlns:h="http://www.zkoss.org/2005/zk/native"
			onUser='lab.value ="event caught by DIV " + org.zkoss.lang.Objects.toString(event.data); Messagebox.show("Do Task Here.")'>
			<h:a/>
			<label id="lab" />
		</div>
		
		
		<div xmlns:h="http://www.zkoss.org/2005/zk/native"
			onUser='lb.value ="event caught by DIV " + org.zkoss.lang.Objects.toString(event.data)'>
			<h:a/>
			<label id="lb" />
		</div>
	</window>
</zk>


This method utilizes the comm function in ZK, by passing the event to the Server and blindly call getElementsByTagName to any 'a' tag. In effect to callback the onUser event listener to the parent of the 'a' tag.

It takes me a while to figure this out, you should buy me a beer if you find it useful.

Regards
Robert Lee

link publish delete flag offensive edit

answered 2009-01-19 09:14:50 +0800

nat gravatar image nat
195 3

Hi Robertlee
Thank you very very much for your workaround... It seems somthing is happening: the onUser event is fired but i receive an error message stating: "Illegal Request: component is required for onUser".. I can't catch where the problem lies..
I took exactly the same code as you typed above... Could you please help more?
P.S: for sure, you deserve a full pint of beer!
-nat

link publish delete flag offensive edit

answered 2009-01-19 10:30:09 +0800

robertlee gravatar image robertlee
561

Hi nat,

my square brackets are parsed away by zk forum, I have corrected the code and please try again.

Regards,
Robert

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: 2008-12-16 08:55:54 +0800

Seen: 2,419 times

Last updated: Jan 20 '09

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