interceptor redirection problem
Hi, here's my code. I want to show an error message if it's impossible to commit. But it seems my action still display the 'success' result. can anybody help me? public String intercept(ActionInvocation invocation) throws Exception { String retour = Action.ERROR; try { sf.getCurrentSession().beginTransaction(); retour = invocation.invoke(); sf.getCurrentSession().getTransaction().commit(); } catch(Exception e) { try{ Transaction tx = sf.getCurrentSession().getTransaction(); if(tx != null tx.isActive()) { tx.rollback(); } }catch (Exception e1) { e1.printStackTrace(); } retour = Action.ERROR; } return retour; } - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: interceptor redirection problem
Please start new threads for new issues. François Rouxel wrote: I want to show an error message if it's impossible to commit. But it seems my action still display the 'success' result. public String intercept(ActionInvocation invocation) throws Exception { String retour = Action.ERROR; try { sf.getCurrentSession().beginTransaction(); retour = invocation.invoke(); sf.getCurrentSession().getTransaction().commit(); } catch(Exception e) { try{ Transaction tx = sf.getCurrentSession().getTransaction(); if(tx != null tx.isActive()) { tx.rollback(); } }catch (Exception e1) { e1.printStackTrace(); } retour = Action.ERROR; } return retour; } See http://struts.apache.org/2.x/docs/writing-interceptors.html, in particular the yellow note talking about PreResultListener. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: interceptor redirection problem
the problem is you are relying on your own ServletFilter this is possibly a configuration problem please display hibernate.xml,hibernate.properties Fairly comprehensive example of configuring hibernate with struts is located at http://www.hibernate.org/105.html Martin __ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. Date: Sat, 31 Jan 2009 04:30:44 -0800 From: rouxe...@yahoo.com Subject: interceptor redirection problem To: user@struts.apache.org Hi, here's my code. I want to show an error message if it's impossible to commit. But it seems my action still display the 'success' result. can anybody help me? public String intercept(ActionInvocation invocation) throws Exception { String retour = Action.ERROR; try { sf.getCurrentSession().beginTransaction(); retour = invocation.invoke(); sf.getCurrentSession().getTransaction().commit(); } catch(Exception e) { try{ Transaction tx = sf.getCurrentSession().getTransaction(); if(tx != null tx.isActive()) { tx.rollback(); } }catch (Exception e1) { e1.printStackTrace(); } retour = Action.ERROR; } return retour; } - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Windows Live™ Hotmail®:…more than just e-mail. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_hm_justgotbetter_explore_012009
Re: interceptor redirection problem
Martin Gainty wrote: the problem is you are relying on your own ServletFilter It's a Struts 2 interceptor. this is possibly a configuration problem please display hibernate.xml,hibernate.properties The issue is with the interceptor and not knowing that the result is executed within the invocation.invoke() method, thus the result is rendered before the interceptor can return the ERROR result. Fairly comprehensive example of configuring hibernate with struts is located at http://www.hibernate.org/105.html That's Struts 1; OP is using Struts 2, and writing, in essence, a Struts 2 version of OpenSessionInView. (Whether or not that's a good pattern is, of course, debatable :) Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
redirection problem with name is input
Hi All, Mapping with redirection type and name is input and value is null but I am not able to validations errors in jsp. Please follow code. action name=addEditWaterhole class=org.paradigmpop.mypopproject.waterhole.actions.AddEditWaterholeAction result name=error type=redirect-action param name=actionNameviewPoPIndex.action/param param name=namespace/p/param /result result name=input type=redirect-action param name=actionNameviewAddEditWaterhole.action/param param name=namespace/p/param param name=popDTO.popid${waterholeDTO.teamPoP.popid}/param /result /action action name=viewAddEditWaterhole class=org.paradigmpop.mypopproject.waterhole.actions.ViewAddEditWaterholeAc tion result name=input type=redirect-action param name=actionNameviewPoPWaterhole.action/param param name=namespace/p/wa/param /result Thank you, Seshagiri V seshagi...@kensium.com. US Main: 877 KENSIUM (536.7486) US Fax: 312.242.3029 Kensium 200 S Wacker Dr, Suite 3100 Chicago, IL 60606 Confidentiality Note: - The information contained in this e-mail is strictly confidential and for the intended use of the addressee only. Any disclosure, use or copying of the information by anyone other than the intended recipient is prohibited. If you have received this message in error, please notify the sender immediately by return e-mail and securely discard this message.
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]
Re: redirection problem
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;ikey_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]
redirection problem
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