-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi people I want to implement the following functionaliity using zk
1. User hits a url.
2. if the user is not logged in the ui rendering should freeze and a pop up should appear
3. the pop up will ask for username and password
4. if the user logs in the ui rendering unfreezes and the page appears
I am facing difficulty in freezing the execution .... I read about event thread processing in zk but that doesnt really solve my problem
Mmmmhh... does it mean you have several free pagesm and then several "access-restricted" pages where you want to force the user to login, right?
Is it necessary to freeze the execution? could it be enough to have a modal popup window asking for credentials and then redirect to desired page if successful? or to a default page if not?
Hi shivam,
You cannot really freeze the execution but you can make similar effect, for example:
<zk> <window id="logWin" border="normal" title="Login (name='ben' and pw='bai')" closable="true" visible="false" position="center, top"> <attribute name="onClose"><![CDATA[ // redirect to the same page Executions.getCurrent().sendRedirect(""); ]]></attribute> name: <textbox id="name" forward="onOK=btn.onClick" onCreate="self.focus();" /> pw: <textbox id="pw" forward="onOK=btn.onClick" /> <button id="btn" label="Login"> <attribute name="onClick"><![CDATA[ if ("ben".equals(name.getValue()) && "bai".equals(pw.getValue())) { Sessions.getCurrent().setAttribute("ALREADY_LOGIN", "true"); // logged in, clear busy mask, hide login window and show content Clients.clearBusy(contentWin); contentWin.getFellow("content").setVisible(true); logWin.setVisible(false); } else { // redirect to the same page Executions.getCurrent().sendRedirect(""); } ]]></attribute> </button> </window> <window id="contentWin" height="100%" width="100%"> <div id="content"> other content </div> </window> <zscript><![CDATA[ // hide content, show busy mask and show login window if not logged in if (!"true".equals(Sessions.getCurrent().getAttribute("ALREADY_LOGIN"))) { contentWin.getFellow("content").setVisible(false); Clients.showBusy(contentWin, "please login"); logWin.setVisible(true); logWin.doOverlapped(); } ]]></zscript> </zk>
Regards,
Ben
Asked: 2012-10-25 13:03:35 +0800
Seen: 68 times
Last updated: Nov 05 '12