Hi ,
Now I’m doing a simple test about SmartClient’s ReLogin feature,however I got some problem.Here is my code:
this is my index.jsp ,which use tu send a RPC to a Servlet to get datas.
<!-- Load isomorphic XML tags for a Java server -->
<%@ taglib uri="/WEB-INF/iscTaglib.xml" prefix="isomorphic" %>
<HTML><HEAD>
<isomorphic:loadISC runat="server"/>
<STYLE>
.headerText {font-family:Verdana,Helvetica,sans-serif; font-size:12px; font-weight:bold; color:black;}
</STYLE><TITLE>
Isomorphic Software Simple Client/Server Communication example
</TITLE>
</HEAD><BODY>
<!-- Begin example code -->
<SCRIPT>
Label.create({
ID: "dataLabel",
position: "relative",
width: 400,
contents:"Click below to fetch data from data-layer..."
});
//
// Clicking on this button sends the current browser time to the server (rpcTarget.jsp) where it
// logged to the console.
//
function isLogin(data){
dataLabel.setContents(data);
}
Button.create({
title: "Get Data",
position: "relative",
width: 150,
click: function () {
RPCManager.send(new Date(),"isLogin(data)",{actionURL:"getData"});
}
});
</SCRIPT>
</BODY>
</HTML>
While I click the button “Get Data”,it send a rpc request whose url is “/getData” ,then it hand the request to GetDataServlet to handle.
here is the method(doPost) of my GetDataServlet’:
System.out.println(this.getClass());
boolean isLogin = request.getParameter("login")!=null?true:false;
RPCManager rpc = null;
if(isLogin)
{
try{
rpc = new RPCManager(request, response);
rpc.send("Welcome to get Data page.");
}catch(Exception e)
{
}
}else
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println("<script src=\"isomorphic/login/reloginFlow.js\"></script>");
out.println(" <BODY><script>");
out.print("while (!window.isc && document.domain.indexOf(\".\") != -1) {");
out.print("try {");
out.print("parent.isc;");
out.print("break;");
out.print("} catch (e) {");
out.print("document.domain = document.domain.replace(/.*?\\./, '');}}");
out.print("var isc = top.isc ? top.isc : window.opener ? window.opener.isc : null;");
out.print("if (isc) isc.RPCManager.delayCall(\"handleLoginRequired\", [window]);");
out.println("</script> </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
while the isLogin is false,the login form that SmartClient supply in reloginFlow.js doesn’t come out.
Is there any wrong in my code???
thanks.