0

Change window witdh/height, and save the size changes

asked 2021-01-08 00:07:52 +0800

NouserTag gravatar image NouserTag
1 1

Hello everyone,

My goal is to make a window resizable (this I have), and, when I change the size of it the next time I open that window, she'll have the size I changed previously.

I'm currently on ZK version 5.0.11, I'm updating an old program, but I need to upgrade is content too. Even if there's any possible way to accomplish this goal, but on a modern version, when i pass that I version, i'll be able to implement it.

Is this possible?

And thanks in advance for helping me!

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2021-01-08 17:22:41 +0800

MDuchemin gravatar image MDuchemin
2560 1 6
ZK Team

Hi there!

I see 2 use cases in that question:

1 - Can a window component keep its dimension during its own lifetime? -> yes it does it automatically Note that in this case, we are talking not only of the same abstract window, but of the same instance of the window component. i.e. if you refresh the page, create a different instance of Window with the same content, etc. you are already out of this use case.

and

2 - Can I extract width and height from the window and reuse them on a different window instance? -> yes, you just need a listener in the right place. This can let you remember a user's choice of sizing between page refresh, or other events that create a new instance of the window component. Basically, you can retrieve these values from the window "onSize" event listener. Once you have these values, you can save them in your business layer, in your session object, or any other relevant location. The next time you need to create the window component, you can just retrieve these values and apply them to the window.

See a fiddle sample for case #2, since I have a feeling that's the one you are looking for ;) https://zkfiddle.org/sample/gfoc24/2-window-stored-width-and-height

link publish delete flag offensive edit

answered 2021-01-11 06:26:29 +0800

NouserTag gravatar image NouserTag
1 1

updated 2021-01-11 06:27:53 +0800

Thanks for your help, I have achieved to save the new size with the "onSize", and with a get/set function in java to apply them, but this only works for the window, not when I change the content size, like textbox.

This only works when a User is on the actual session, when he leaves, the value goes away. I can't modifie the database to make a table to save the values...

What i wanted to accomplish is, when the user changes any component/window, the next time he entered that window, the changes where still there.

(I believe that I didn't make it clear in the question, sorry) But I believe what i whant to accomplish is a little to advance

link publish delete flag offensive edit

answered 2021-01-12 14:37:18 +0800

MDuchemin gravatar image MDuchemin
2560 1 6
ZK Team

The same logic can be apply to most components that support the sizable workflow.

If you want persistence, you need to store something somewhere :D if not in the database, then in the user session, or even as a cookie in the user's browser (if you don't have too many of these components), etc. That is entirely up to you and how your application is structured. ZK only cares about presentation to the end-user.

Once you receive the size from the size event, you store it somewhere. When the user want to pull the same page again, they are not pulling the same "components". Instead a new set of component instances is created, and you can apply the saved sizes to them.

To be honest, I'm still not entirely sure what the intended use is. Storing these sizes in session is reasonable as long as the user session exists. Storing in database would only make sense if you already have a user table in database.

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
2 followers

RSS

Stats

Asked: 2021-01-08 00:07:52 +0800

Seen: 15 times

Last updated: Jan 12 '21

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