-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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!
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?
Could you post those errors?
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.
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!
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.
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.
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" />
Auditor review the zul snapshot with a browser.
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:
I'm not sure whether it's possible or not. This is based on my understanding to your use case.
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!
Asked: 2022-10-09 10:16:32 +0800
Seen: 21 times
Last updated: Oct 24 '22