0

How to get window instance in a servlet?

asked 2010-05-24 03:15:02 +0800

swarnendude gravatar image swarnendude
45

Hi,

I am new to ZK and I want to get the window instance of my zul file in a servlet. I will be using this instance when I will send an AJAX request from my javascript file.

My window defn is :

<window id="w1" use="org.zkoss.zss.app.MainWindow" height="100%" width="100%" style="margin:0px;padding:0px">

I want to use MainWindow class instance in my servlet. If I instantiate it as

MainWindow mw = new MainWindow();

then it gives me initialization NullPointerException.

How to implement this?

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2010-05-24 06:48:34 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-05-24 06:48:55 +0800

Executions.ceateComponents( "/WEB-INF/yourPages/ w1.zul", parent, paramMap);

link publish delete flag offensive edit

answered 2010-05-24 07:47:00 +0800

swarnendude gravatar image swarnendude
45

updated 2010-05-24 07:53:15 +0800

Hi terrytornado,

Thank you for your reply. Do I need to execute the command :

Executions.ceateComponents( "/WEB-INF/yourPages/ w1.zul", parent, paramMap);

from zscript tag or I can directly access it form my servlet? I mean if my client page is index.zul, then can I access it from my servlet (to which I am sending the AJAX request from javascript) as " /WEB-INF/yourPages/ index.zul"? What will be "parent" and "parentMap"?

I am new to ZK and am very confused to work with ZK Spreadsheet application.

link publish delete flag offensive edit

answered 2010-05-24 07:59:26 +0800

swarnendude gravatar image swarnendude
45

updated 2010-05-24 07:59:56 +0800

And also, how to create the instance of org.zkoss.zss.app.MainWindow a function of which I am going to invoke?

link publish delete flag offensive edit

answered 2010-05-24 12:55:18 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-05-24 12:56:05 +0800

1. if you pointed your browser to a zul page, the zk loader parses the zul-file, creates the components, looks for a defined controller, handles the events, renders the page and send back to the client.
You can call such a flow from java i.e. with the method Executions.createComponents(...)

2. If you only work with richlets(pure java) than you must create all components in java. And yes, than you can create an instance of this view class with new xxx().

best
Stephan

link publish delete flag offensive edit

answered 2010-05-25 02:42:36 +0800

swarnendude gravatar image swarnendude
45

updated 2010-05-25 02:46:00 +0800

Hi Stephan, thank you for your reply. I did the same way as you told, but...

"the zk loader parses the zul-file, creates the components, looks for a defined controller,......" - Can I get the component which browser creates? I don't want to create the component myself.

I just want to replace the forward requests sent by a menuitem to its controller by my javascript function sending AJAX request. If I create the component and pass it, then it halts always at the getFellow() method saying "Fellow not defined"!!

Can't I get the current instance of the controller (MainWindow class) which is being used by the browser such that I just need to work on the functionality forgetting initialization of the Spreadsheet components (there are lots)?

link publish delete flag offensive edit

answered 2010-05-25 03:06:08 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Please, search for GenericForwardComposer and read the MVC Smalltalks. There you can read about the history and working of the composers and why they made the life easier. If you extends from GenericForwardComposer you have full access to all components that are defined in your zul-file by an autowireing feature of this composer.

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: 2010-05-24 03:15:02 +0800

Seen: 823 times

Last updated: May 25 '10

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