0

Freezing the execution

asked 2012-10-25 13:03:35 +0800

shivam gravatar image shivam
66

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

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-10-26 11:27:35 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

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?

link publish delete flag offensive edit

answered 2012-11-05 09:30:30 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

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

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: 2012-10-25 13:03:35 +0800

Seen: 68 times

Last updated: Nov 05 '12

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