-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi there,
here is my situation:
I have 2 ZK applications (not on the same server) A and B. In A I want to use B , which is some kind of browser, to select an object and send its name(or itself) back to A by pressing a "select" button in B.
I managed to communicate between A and B over cookies, but pressing the button in B won't cause A to read data from cookies.
I've read something about event queries but the needed scope (GROUP) is only available in ZK EE versions.
Can anyone help me with this?
There are thousand of ways to achieve this, probably the last recommendable one is a cookie.
A stupid straight forward one?
Assuming that by a security point of view there is no issue or you managed it, app A just need to expose a dedicated servlet or even just a callback.zul file:
<window>
<zscript><![CDATA[
String id = execution.getParameter("id");
]]></zscript>
<label value="${id}"/>
</window>
so when in app B the user push the "select" button you have just to redirect to callback.zul?id=123. In callback.zul you are back to your app A and with the selected ID you can do what you have to do.
I repeat: the cookie was the last option... this is just a possible (stupid) other way to manage your scenario.
have a look here at the zk-rabbitmq
Thanks for the answer but it still doesn't work the way I want.
I tried this:
In AppA:
Executions.getCurrent().sendRedirect("h t t p://localhost:8080/AppB/main.zul?sendbackuri=/AppA/main.zul");
That will show up the browser and I can select my object and send the id back with this code below:
In AppB:
Executions.getCurrent().sendRedirect("h t t p://localhost:8080/AppA/main.zul?id=123");
The problem is, that the redirect doesn't redirect to the original AppA, but to a new AppA* . AppA* is a complete new instance and doesn't share any values with AppA. So, if i made some changes to values of AppA and redirect to AppA, all changes are gone.
I tried to load AppB with
Window w = (Window) Executions.getCurrent().createComponents("h t t p://localhost:8080/AppB/main.zul", parentThis, mapData);
w.doModal();
But I couldn't find a way to use "createComponents" in AppA to create .zuls from AppB.
P.S. I used spaces in "h t t p", because I am not allowed to post links here due to low karma.
a.zul
<window title="intra frame communication" border="normal">
<textbox id="here" hflex="1" />
<script type="text/javascript">
function saySomething(message) {
jQuery("$here").val(message);
}
</script>
<iframe height="100px" width="100px" src="b.zul" />
</window>
b.zul
<a href="javascript:window.top.saySomething('hello world!')">greetings from app B</a>
I repeat: there are many ways to achieve this... the one i'm suggesting you is probably the stupidest but fastest. If your scenario is too complex you should try to consider maybe JSR268 (and the intra portlets communication) or an event queue approach as Stephan suggested.
Asked: 2013-03-22 14:54:27 +0800
Seen: 48 times
Last updated: Mar 29 '13