0

How to snapshot window(components) with zul file directly

asked 2022-10-09 10:16:32 +0800

jasonhoo gravatar image jasonhoo
104 4

updated 2022-10-09 15:50:20 +0800

Now, there are two ways to access the server-side model: zul page and mobile terminal (front-end and back-end separation, non-zul); When accessing through the Zul page, the server can access the model through Executions.createComponents and generate the corresponding window object (each control on the page accesses the model data through Composer), and then I saves the window object as an xml snapshot:

Window window = (Window) Executions.createComponents(zulFileName, null, null);

When the mobile terminal accesses the server model, the session of Zk is created through httpsession, and the req/resp information of http is used to create Execution, but there are various errors when calling createComponents...

HttpSession session = req.getSession(true);
Session zkSession = WebManager.getSession(session.getServletContext(), req);
Execution execution = new ExecutionImpl(session.getServletContext(), req, resp, null, null);
UiEngine engine = ((WebAppCtrl)zkSession.getWebApp()).getUiEngine();
engine.activate(execution) ;
ExecutionsCtrl.setCurrent(execution);
Component[] components = engine.createComponents(execution, execution.getPageDefinition(zulFileName), null, null, null, null, null);
Window window = (Window) components[0];
engine.deactivate(execution);

I wonder if there are any existing method or other good ideas? Thanks!

delete flag offensive retag edit

7 Answers

Sort by ยป oldest newest most voted
0

answered 2022-10-10 18:48:44 +0800

hawk gravatar image hawk
3073 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2022-10-11 09:14:47 +0800

unclear use case

I can't understand your use case clearly for the mobile terminal. What's the mobile terminal? Is it a browser? It sounds like it's a special scenario. How do you "saves the window object as an xml snapshot"? Could you explain more about your environment?

there are various errors when calling createComponents...

Could you post those errors?

regarding your code

It looks like you write code like what ZK DHtmlLayoutServlet does. Why do you need to create an ExecutionImpl by yourself instead of getting an Execution by ZK API like Executions.getCurrent()? It looks like you do something special.

link publish delete flag offensive edit
0

answered 2022-10-11 10:08:37 +0800

jasonhoo gravatar image jasonhoo
104 4

updated 2022-10-11 10:25:34 +0800

Requirement : For business review or authorization and operational audit, record a snapshot of the page when the client submit.

In the old version of the application, the zul page deployed through the WAR, because the DHtmlLayoutServlet is called, the Window object is created by call Executions.createComponents on the server side, and then all the sub-objects traverse the zul file that generates the static value as a snapshot;

Now mobile terminals and even third-party API access services directly. They do not submit data through the zul page, but they also want to retain the original zul snapshot mode for business processing and auditing. Therefore, I need to create an Execution according to myself to create a window object and save the snapshot.

The various errors in the past were mainly that Executions.getCurrent(), UIEngine, etc. returned null. It's OK now!

I want to know if there are ready-made or better solutions, thank you!

link publish delete flag offensive edit
0

answered 2022-10-12 13:04:08 +0800

hawk gravatar image hawk
3073 1 5
http://hawkphoenix.blogsp... ZK Team

I can understand if a user sumbits on a zul page, then you make a snapshot of a page for audit. But if a mobile terminal sends a HTTP request directly to your service, not handled by zul, then why do you still want to make a snapshot of zul?

Could you just record what users send via HTTP request for audit? I think all required inputs should be sent by the parameters of user-sent-request. Besides, record parameters should consume less memory than a zul snapshot.

It seems what you want to do is almost like a DHtmlLayoutServlet does. You plan to simulate the processing of a request to a zul. Currently, there is no good way to do this since this is out of ZK use cases.

The only possible idea I could think is if you can call DHtmlLayoutServlet with mocked request and response, maybe you don't need to implement something similar as DHtmlLayoutServlet by yourself.

snapshot

I don't know what content in a zul page snapshot. As you mentioned

...traverse the zul file that generates the static value as a snapshot..

Do you mean traverse each input component to collect user input from zul page? e.g. get value from a textbox.

If so, then you can just extract and record the parameters from an HTTP request to a service into an audit record instead of building components from a zul. Anyway, you just need to record user input for audit, not components.

Your use case is quite special. If my understanding is wrong, please provide more details or screenshots.

link publish delete flag offensive edit
0

answered 2022-10-12 15:30:52 +0800

jasonhoo gravatar image jasonhoo
104 4

Thank you very much for your patient reply!

First, explain the application scenario 10 years ago: customers submit data through the zul web app, the data (including digital signatures) will be saved in the database, and the zul snapshot will be saved as file data; the system background personnel will review and authorize the business through the zul snapshot. Now, some customers submit data through mobile terminal or webservice directly instead of the zul web app, but the review and authorization mode of the system background personnel do not want to change.

Second, about snapshots, explain with an example: input/view zul page is :

<textbox id="A2" apply="org.sss.presentation.zk.ZkComposer" maxlength="22" style="position:absolute;left:94px;top:57px;height:20px;width:230.0px;ime-mode:disabled;"> 
    <custom-attributes fieldUrl="bopquep\rptno"/>
</textbox>

snapshots zul page is :

<textbox readonly="true" text="User input data" />
link publish delete flag offensive edit

Comments

Does the auditor review the zul snapshot with a browser? or just read zul file in XML format?

hawk ( 2022-10-12 18:21:31 +0800 )edit
0

answered 2022-10-13 10:09:10 +0800

jasonhoo gravatar image jasonhoo
104 4

updated 2022-10-13 10:11:32 +0800

Auditor review the zul snapshot with a browser.

  1. the data is fixed;
  2. manual input,interface import and original data will display by different css (for example with red / yellow / green underline);
  3. more attention should be paid to the data manual input, interface import.
link publish delete flag offensive edit

Comments

does my suggestion below work for you?

hawk ( 2022-10-24 09:24:19 +0800 )edit
0

answered 2022-10-14 13:38:40 +0800

hawk gravatar image hawk
3073 1 5
http://hawkphoenix.blogsp... ZK Team

If an auditor reviews user submission in a browser by visiting a zul. I think you can restore the user input into a zul in another way. Don't try to simulate an HTTP request processing in DHtmlLayoutServlet. I suppose you can:

  1. when a mobile terminal requests the service, record the user input (arguments)
  2. when an auditor wants to review, create components with the zul for review and set each input component with recorded user input from step 1.

I'm not sure whether it's possible or not. This is based on my understanding to your use case.

link publish delete flag offensive edit
0

answered 2022-10-24 13:46:09 +0800

jasonhoo gravatar image jasonhoo
104 4

Thanks for your suggestions and continued follow up! There are many transactions in the old system, and there are thousands of zul pages involving snapshots. Considering the stability and continuity of the system, we still use the solution of generating Execution by ourselves and have been successfully launched.

Thank you again!

link publish delete flag offensive edit

Comments

I see. Thanks for your feedback.

hawk ( 2022-10-25 10:20:50 +0800 )edit
Your answer
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: 2022-10-09 10:16:32 +0800

Seen: 21 times

Last updated: Oct 24

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