a test harness import com.mockobjects.dynamic.C; com.opensymphony.xwork2.ActionInvocation invocation= (com.opensymphony.xwork2.ActionInvocation) new Mock(com.opensymphony.xwork2.ActionInvocation.class).proxy(); org.apache.struts2.dispatcher.HttpHeaderResult result=new org.apache.struts2.dispatcher.HttpHeaderResult(); com.mockobjects.dynamic.Mock responseMock = new com.mockobjects.dynamic.Mock(javax.servlet.http.HttpServletResponse.class); javax.servlet.http.HttpServletResponse response= (javax.servlet.http.HttpServletResponse) responseMock.proxy();
org.apache.struts2.ServletActionContext.setResponse(response); XWorkConverter.getInstance().setObjectTypeDeterminer(com.opensymphony.xwork2 util.ObjectTypeDeterminerFactory.getInstance()); //parameters java.util.Map params = new java.util.HashMap(); params.put("headers.ajax", "${ajax}"); //values.. java.util.Map values = new java.util.HashMap(); values.put("ajax", "ajax"); //push the values into context stack com.opensymphony.xwork2.ActionContext.getContext().getValueStack().push(valu es); //make OGNL accessible com.opensymphony.xwork2.util.OgnlUtil.setProperties(params, result); //populate MockObject with a header responseMock.expect("addHeader", C.args(C.eq("ajax"), C.eq("ajax"))); //execute result.execute(invocation); //end server code //client side //some dojo javascript to test client functionality.. var headers=http.getAllResponseHeaders(); var ret={}; ret.toString=function() { return headers; }; var key_value=headers.split(/[\r\n]+/g); for(var i=0;i<key_value.length;i++) { var pair=key_value[i].match(/^([^:]+)\s*:\s*(.+)$/i); if(pair) { key=pair[1]; value=pair[2]; } anyone else? Martin ----- Original Message ----- From: "Jeromy Evans" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <user@struts.apache.org> Sent: Saturday, March 15, 2008 5:50 AM Subject: Re: redirection problem > This discussion should give you some ideas: > > http://www.nabble.com/Interceptors-with-Ajax-Actions-td15706322.html > > > matthieu martin wrote: > > Hi all. > > > > I am handling login issue through an interceptor. Basically it looks in the > > session if a user entry exists before letting you go through to the > > administration panels. This works fine. > > > > In my admin, I use a lot of Ajax (with dojo) so I never have a single full > > page reload. I use submits or anchor tags to do that. Those tags use the > > "targets" parameter to know which part of the page is to be refreshed. > > > > And here is my problem : > > > > I click on a <s:a> or a <s:submit> tag, my interceptor catches the request, > > sees that I am not logged in anymore, and does the redirection towards the > > login page ... inside the div specified as a target ! > > > > I understand very well this matter, and it's all too logical. Nevertheless, > > I've been turning this issue upside down for days now and I can't figure a > > way to refresh the whole page when I'm not logged in anymore, or only > > refresh the div I want when my interceptor says everything's fine. > > > > Is there a way to break to target parameter so that I could simply redirect > > toward an action which would refresh the whole page ? > > > > Does anyone have an idea ? > > > > I'm sort of out of solutions .... > > > > Matthieu > > > > > > ------------------------------------------------------------------------ > > > > No virus found in this incoming message. > > Checked by AVG. > > Version: 7.5.519 / Virus Database: 269.21.7/1329 - Release Date: 14/03/2008 12:33 PM > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]